# HG changeset patch # User Goffi # Date 1440691155 -7200 # Node ID f681788097ba1903f58e7ba08fe15d37feb7edb2 # Parent 566908d483f655be3b485aed2fa8f30c793a2c41 core (plugins): detect import_name conflicts diff -r 566908d483f6 -r f681788097ba src/core/sat_main.py --- 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):