diff options
Diffstat (limited to 'src/plugin_manager.py')
-rw-r--r-- | src/plugin_manager.py | 45 |
1 files changed, 14 insertions, 31 deletions
diff --git a/src/plugin_manager.py b/src/plugin_manager.py index d4cc7384..549753a9 100644 --- a/src/plugin_manager.py +++ b/src/plugin_manager.py @@ -5,12 +5,9 @@ the API together. Defines also a bunch of variables related to the plugin env. """ -import imp import os from os import path import logging -from gettext import gettext as _ -from sys import version_info import core import tabs @@ -44,9 +41,8 @@ class PluginManager(object): self.tab_keys = {} self.roster_elements = {} - if version_info[1] >= 3: # 3.3 & > - from importlib import machinery - self.finder = machinery.PathFinder() + from importlib import machinery + self.finder = machinery.PathFinder() self.initial_set_plugins_dir() self.initial_set_plugins_conf_dir() @@ -70,29 +66,16 @@ class PluginManager(object): try: module = None - if version_info[1] < 3: # < 3.3 - if name in self.modules: - imp.acquire_lock() - module = imp.reload(self.modules[name]) - else: - file, filename, info = imp.find_module(name, - self.load_path) - imp.acquire_lock() - module = imp.load_module(name, file, filename, info) - else: # 3.3 & > - loader = self.finder.find_module(name, self.load_path) - if not loader: - self.core.information('Could not find plugin: %s' % name) - return - module = loader.load_module() - + loader = self.finder.find_module(name, self.load_path) + if not loader: + self.core.information('Could not find plugin: %s' % name) + return + module = loader.load_module() except Exception as e: log.debug("Could not load plugin %s", name, exc_info=True) self.core.information("Could not load plugin %s: %s" % (name, e), 'Error') finally: - if version_info[1] < 3 and imp.lock_held(): - imp.release_lock() if not module: return @@ -109,8 +92,8 @@ class PluginManager(object): except Exception as e: log.error('Error while loading the plugin %s', name, exc_info=True) if notify: - self.core.information(_('Unable to load the plugin %s: %s') % - (name, e), + self.core.information('Unable to load the plugin %s: %s' % + (name, e), 'Error') self.unload(name, notify=False) else: @@ -147,8 +130,8 @@ class PluginManager(object): self.core.information('Plugin %s unloaded' % name, 'Info') except Exception as e: log.debug("Could not unload plugin %s", name, exc_info=True) - self.core.information(_("Could not unload plugin %s: %s") % - (name, e), + self.core.information("Could not unload plugin %s: %s" % + (name, e), 'Error') def add_command(self, module_name, name, handler, help, @@ -157,7 +140,7 @@ class PluginManager(object): Add a global command. """ if name in self.core.commands: - raise Exception(_("Command '%s' already exists") % (name,)) + raise Exception("Command '%s' already exists" % (name,)) commands = self.commands[module_name] commands[name] = core.Command(handler, help, completion, short, usage) @@ -244,7 +227,7 @@ class PluginManager(object): already exists. """ if key in self.core.key_func: - raise Exception(_("Key '%s' already exists") % (key,)) + raise Exception("Key '%s' already exists" % (key,)) keys = self.keys[module_name] keys[key] = handler self.core.key_func[key] = handler @@ -295,7 +278,7 @@ class PluginManager(object): except: pass except OSError as e: - self.core.information(_('Completion failed: %s' % e), 'Error') + self.core.information('Completion failed: %s' % e, 'Error') return plugins_files = [name[:-3] for name in names if name.endswith('.py') and name != '__init__.py' and not name.startswith('.')] |