diff options
author | Chuancong Gao <chuanconggao@users.noreply.github.com> | 2018-05-15 15:39:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-15 15:39:55 -0700 |
commit | 7842f83dcf06addd940125ddc68d7d3b8ae882d7 (patch) | |
tree | 49f01c3ec1affdbc0356d2eeb221a2701e148e17 /examples/plugin_avfs.py | |
parent | 6eae1e1480df9d66e7d851b332ce636a7d95af11 (diff) | |
parent | fe1989b52c871c23327bfd6296330bebabc47ad1 (diff) | |
download | ranger-7842f83dcf06addd940125ddc68d7d3b8ae882d7.tar.gz |
Merge branch 'master' into bugfix
Diffstat (limited to 'examples/plugin_avfs.py')
-rw-r--r-- | examples/plugin_avfs.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/examples/plugin_avfs.py b/examples/plugin_avfs.py new file mode 100644 index 00000000..07968a03 --- /dev/null +++ b/examples/plugin_avfs.py @@ -0,0 +1,33 @@ +# Tested with ranger 1.9.1 +# +# A very simple and possibly buggy support for AVFS +# (http://avf.sourceforge.net/), that allows ranger to handle +# archives. +# +# Run `:avfs' to browse the selected archive. + +from __future__ import (absolute_import, division, print_function) + +import os +import os.path + +from ranger.api.commands import Command + + +class avfs(Command): # pylint: disable=invalid-name + avfs_root = os.path.join(os.environ["HOME"], ".avfs") + avfs_suffix = "#" + + def execute(self): + if os.path.isdir(self.avfs_root): + archive_directory = "".join([ + self.avfs_root, + self.fm.thisfile.path, + self.avfs_suffix, + ]) + if os.path.isdir(archive_directory): + self.fm.cd(archive_directory) + else: + self.fm.notify("This file cannot be handled by avfs.", bad=True) + else: + self.fm.notify("Install `avfs' and run `mountavfs' first.", bad=True) |