about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-09-28 23:08:55 +0200
committerhut <hut@lavabit.com>2011-09-28 23:08:55 +0200
commitdc27af1255a285bc5387e00dc459f55043a4c092 (patch)
treef9710e3c1d8a287b293b5df5370925fd2689bbcf /ranger
parentea2dd9974b5b25a206048b2747e9184c3e875f8d (diff)
downloadranger-dc27af1255a285bc5387e00dc459f55043a4c092.tar.gz
added experimental plugin system
Diffstat (limited to 'ranger')
-rw-r--r--ranger/core/helper.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/ranger/core/helper.py b/ranger/core/helper.py
index ad5541f5..d1ef3ed0 100644
--- a/ranger/core/helper.py
+++ b/ranger/core/helper.py
@@ -117,6 +117,31 @@ def load_settings(fm, clean):
 			import keys
 		except ImportError:
 			pass
+
+		# Load plugins
+		try:
+			plugindir = fm.confpath('plugins')
+			plugins = [p[:-3] for p in os.listdir(plugindir) \
+					if p.endswith('.py') and not p.startswith('_')]
+		except:
+			pass
+		else:
+			if not os.path.exists(fm.confpath('plugins', '__init__.py')):
+				f = open(fm.confpath('plugins', '__init__.py'), 'w')
+				f.close()
+			import types
+			ranger.fm = fm
+			for plugin in sorted(plugins):
+				try:
+					mod = __import__('plugins', fromlist=[plugin])
+					fm.log.append("Loaded plugin '%s'." % module)
+				except Exception as e:
+					fm.log.append("Error in plugin '%s'" % plugin)
+					import traceback
+					for line in traceback.format_exception_only(type(e), e):
+						fm.log.append(line)
+			ranger.fm = None
+
 		allow_access_to_confdir(ranger.arg.confdir, False)
 	else:
 		comcont = ranger.api.commands.CommandContainer()