Mercurial > libervia-backend
changeset 1503:f681788097ba
core (plugins): detect import_name conflicts
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 27 Aug 2015 17:59:15 +0200 |
parents | 566908d483f6 |
children | a2e4b976e707 |
files | src/core/sat_main.py |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/sat_main.py Thu Aug 27 17:59:11 2015 +0200 +++ b/src/core/sat_main.py Thu Aug 27 17:59:15 2015 +0200 @@ -145,7 +145,7 @@ import sat.plugins plugins_path = os.path.dirname(sat.plugins.__file__) plug_lst = [os.path.splitext(plugin)[0] for plugin in map(os.path.basename, glob(os.path.join(plugins_path, "plugin*.py")))] - __plugins_to_import = {} # plugins we still have to import + plugins_to_import = {} # plugins we still have to import for plug in plug_lst: plugin_path = 'sat.plugins.' + plug try: @@ -155,10 +155,14 @@ continue mod = sys.modules[plugin_path] plugin_info = mod.PLUGIN_INFO - __plugins_to_import[plugin_info['import_name']] = (plugin_path, mod, plugin_info) + import_name = plugin_info['import_name'] + if import_name in plugins_to_import: + log.error(_(u"Name conflict for import name [{import_name}], can't import plugin [{name}]").format(**plugin_info)) + continue + plugins_to_import[import_name] = (plugin_path, mod, plugin_info) while True: - self._import_plugins_from_dict(__plugins_to_import) - if not __plugins_to_import: + self._import_plugins_from_dict(plugins_to_import) + if not plugins_to_import: break def _import_plugins_from_dict(self, plugins_to_import, import_name=None, optional=False):