diff options
author | hut <hut@lepus.uberspace.de> | 2016-07-04 21:45:50 +0200 |
---|---|---|
committer | hut <hut@lepus.uberspace.de> | 2016-07-04 21:46:45 +0200 |
commit | a60b15b75e0d78504903bebfc45af404acfecd93 (patch) | |
tree | e88a36aee880f70ef1fbc912077688c84f7dabc1 | |
parent | f2c18a523e054308aca795b00030bfdf4de5985b (diff) | |
download | ranger-a60b15b75e0d78504903bebfc45af404acfecd93.tar.gz |
use importlib on py2.7+ to fix loading commands from plugins
-rw-r--r-- | ranger/core/main.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/ranger/core/main.py b/ranger/core/main.py index 000ded68..118a7480 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -303,8 +303,16 @@ def load_settings(fm, clean): ranger.fm = fm for plugin in sorted(plugins): try: - module = __import__('plugins', fromlist=[plugin]) - fm.commands.load_commands_from_module(module) + try: + # importlib does not exist before python2.7. It's + # required for loading commands from plugins, so you + # can't use that feature in python2.6. + import importlib + except ImportError: + module = __import__('plugins', fromlist=[plugin]) + else: + module = importlib.import_module('plugins.' + plugin) + fm.commands.load_commands_from_module(module) fm.log.append("Loaded plugin '%s'." % plugin) except Exception as e: fm.log.append("Error in plugin '%s'" % plugin) |