From 1b2b8a0a80de17ea053002fdd124055d2798029a Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Tue, 25 Oct 2016 13:03:34 +0200 Subject: devtool: Load plugins in a well defined order To allow devtool plugins in one layer to shadow another in a well defined way, first search BBPATH/lib/devtool directories and then scripts/lib/devool and load only the first found. The previous search and load loop would load all found plugins with the ones found later replacing any found before. Signed-off-by: Ola x Nilsson Signed-off-by: Ross Burton --- scripts/lib/scriptutils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts/lib/scriptutils.py') diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py index 5ccc027968..27d82b62b8 100644 --- a/scripts/lib/scriptutils.py +++ b/scripts/lib/scriptutils.py @@ -52,10 +52,14 @@ def load_plugins(logger, plugins, pluginpath): if fp: fp.close() + def plugin_name(filename): + return os.path.splitext(os.path.basename(filename))[0] + + known_plugins = [plugin_name(p.__name__) for p in plugins] logger.debug('Loading plugins from %s...' % pluginpath) for fn in glob.glob(os.path.join(pluginpath, '*.py')): - name = os.path.splitext(os.path.basename(fn))[0] - if name != '__init__': + name = plugin_name(fn) + if name != '__init__' and name not in known_plugins: plugin = load_plugin(name) if hasattr(plugin, 'plugin_init'): plugin.plugin_init(plugins) -- cgit 1.2.3-korg