From 00366b27e12023d31dc445660df05000cc47a114 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Sun, 1 Apr 2018 23:32:00 +0200 Subject: examples: Add plugin_avfs.py, a simple AVFS integration http://avf.sourceforge.net/ --- examples/plugin_avfs.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 examples/plugin_avfs.py (limited to 'examples/plugin_avfs.py') diff --git a/examples/plugin_avfs.py b/examples/plugin_avfs.py new file mode 100644 index 00000000..6910533c --- /dev/null +++ b/examples/plugin_avfs.py @@ -0,0 +1,31 @@ +# 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) + +from ranger.api.commands import Command +import os +import os.path + +class avfs(Command): + 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) -- cgit 1.4.1-2-gfad0 From 8a9ede42a95b703daa35364aca32b672cfb680f7 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Sun, 1 Apr 2018 23:56:01 +0200 Subject: Fix pylint --- examples/plugin_avfs.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'examples/plugin_avfs.py') diff --git a/examples/plugin_avfs.py b/examples/plugin_avfs.py index 6910533c..07968a03 100644 --- a/examples/plugin_avfs.py +++ b/examples/plugin_avfs.py @@ -8,11 +8,13 @@ from __future__ import (absolute_import, division, print_function) -from ranger.api.commands import Command import os import os.path -class avfs(Command): +from ranger.api.commands import Command + + +class avfs(Command): # pylint: disable=invalid-name avfs_root = os.path.join(os.environ["HOME"], ".avfs") avfs_suffix = "#" -- cgit 1.4.1-2-gfad0