about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorWojciech Siewierski <wojciech.siewierski@onet.pl>2018-04-02 00:01:46 +0200
committerGitHub <noreply@github.com>2018-04-02 00:01:46 +0200
commita30b5e5b517a04f35e79a41a624aaedf187f6a36 (patch)
tree940e2fc6a7590ee93027230c8db7a4664c117c51
parente09e2648752d24361e94d9bba66c5a1049fd2fb5 (diff)
parent8a9ede42a95b703daa35364aca32b672cfb680f7 (diff)
downloadranger-a30b5e5b517a04f35e79a41a624aaedf187f6a36.tar.gz
Merge pull request #1133 from Vifon/avfs_plugin
Add a simple AVFS integration
-rw-r--r--examples/plugin_avfs.py33
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)