summaryrefslogtreecommitdiff
path: root/src/plugin_manager.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-11-21 23:30:59 +0100
committermathieui <mathieui@mathieui.net>2012-11-21 23:30:59 +0100
commitd3e1f8085ee843a0630a6a45fb85314b655eaaac (patch)
tree12d9daa00ee96d7d1518e36f7eb1d962e407979f /src/plugin_manager.py
parent70d389ade75e77ab8a28957641b98c235f62969d (diff)
downloadpoezio-d3e1f8085ee843a0630a6a45fb85314b655eaaac.tar.gz
poezio-d3e1f8085ee843a0630a6a45fb85314b655eaaac.tar.bz2
poezio-d3e1f8085ee843a0630a6a45fb85314b655eaaac.tar.xz
poezio-d3e1f8085ee843a0630a6a45fb85314b655eaaac.zip
Hack to make importlib work on python < 3.3
Diffstat (limited to 'src/plugin_manager.py')
-rw-r--r--src/plugin_manager.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/plugin_manager.py b/src/plugin_manager.py
index f6a54058..4bab84df 100644
--- a/src/plugin_manager.py
+++ b/src/plugin_manager.py
@@ -6,6 +6,7 @@ plugin env.
"""
from importlib import machinery
+from sys import version_info
import os
from os import path
import sys
@@ -42,7 +43,13 @@ default_plugin_path = path.join(path.dirname(path.dirname(__file__)), 'plugins')
sys.path.append(default_plugin_path)
sys.path.append(plugins_dir)
-finder = machinery.PathFinder()
+
+PY33 = version_info[1] >= 3
+if not PY33:
+ from importlib._bootstrap import _DefaultPathFinder
+ finder = _DefaultPathFinder
+else:
+ finder = machinery.PathFinder
class PluginManager(object):
"""
@@ -72,7 +79,7 @@ class PluginManager(object):
if not loader:
self.core.information('Could not find plugin: %s' % name, 'Error')
return
- module = loader.load_module()
+ module = loader.load_module(name)
except Exception as e:
import traceback
log.debug("Could not load plugin: \n%s", traceback.format_exc())
@@ -253,7 +260,11 @@ class PluginManager(object):
all .py files in plugins_dir
"""
try:
- names = os.listdir(plugins_dir)
+ try:
+ names = set(os.listdir(default_plugin_path))
+ except:
+ names = set()
+ names |= set(os.listdir(plugins_dir))
except OSError as e:
self.core.information(_('Completion failed: %s' % e), 'Error')
return