diff options
Diffstat (limited to 'scripts/lib')
-rw-r--r-- | scripts/lib/wic/plugin.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/scripts/lib/wic/plugin.py b/scripts/lib/wic/plugin.py index 36a120bb1c..094a878e0f 100644 --- a/scripts/lib/wic/plugin.py +++ b/scripts/lib/wic/plugin.py | |||
@@ -31,7 +31,7 @@ logger = logging.getLogger('wic') | |||
31 | 31 | ||
32 | class PluginMgr: | 32 | class PluginMgr: |
33 | _plugin_dirs = [] | 33 | _plugin_dirs = [] |
34 | _loaded = [] | 34 | _plugins = {} |
35 | 35 | ||
36 | @classmethod | 36 | @classmethod |
37 | def get_plugins(cls, ptype): | 37 | def get_plugins(cls, ptype): |
@@ -39,6 +39,9 @@ class PluginMgr: | |||
39 | if ptype not in PLUGIN_TYPES: | 39 | if ptype not in PLUGIN_TYPES: |
40 | raise WicError('%s is not valid plugin type' % ptype) | 40 | raise WicError('%s is not valid plugin type' % ptype) |
41 | 41 | ||
42 | if ptype in cls._plugins: | ||
43 | return cls._plugins[ptype] | ||
44 | |||
42 | # collect plugin directories | 45 | # collect plugin directories |
43 | if not cls._plugin_dirs: | 46 | if not cls._plugin_dirs: |
44 | cls._plugin_dirs = [os.path.join(os.path.dirname(__file__), 'plugins')] | 47 | cls._plugin_dirs = [os.path.join(os.path.dirname(__file__), 'plugins')] |
@@ -52,13 +55,12 @@ class PluginMgr: | |||
52 | # load plugins | 55 | # load plugins |
53 | for pdir in cls._plugin_dirs: | 56 | for pdir in cls._plugin_dirs: |
54 | ppath = os.path.join(pdir, ptype) | 57 | ppath = os.path.join(pdir, ptype) |
55 | if ppath not in cls._loaded: | 58 | if os.path.isdir(ppath): |
56 | if os.path.isdir(ppath): | 59 | for fname in os.listdir(ppath): |
57 | for fname in os.listdir(ppath): | 60 | if fname.endswith('.py'): |
58 | if fname.endswith('.py'): | 61 | mname = fname[:-3] |
59 | mname = fname[:-3] | 62 | mpath = os.path.join(ppath, fname) |
60 | mpath = os.path.join(ppath, fname) | 63 | SourceFileLoader(mname, mpath).load_module() |
61 | SourceFileLoader(mname, mpath).load_module() | ||
62 | cls._loaded.append(ppath) | ||
63 | 64 | ||
64 | return pluginbase.get_plugins(ptype) | 65 | cls._plugins[ptype] = pluginbase.get_plugins(ptype) |
66 | return cls._plugins[ptype] | ||