From cabf27424fca40883d301bba09fc854abff6de77 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Mon, 12 Mar 2012 19:00:32 -0700 Subject: Cleanup plugin import logic. Checking for a 'xep' or 'rfc' attribute is more reliable for detecting an old style plugin than 'name'. --- sleekxmpp/plugins/base.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'sleekxmpp') diff --git a/sleekxmpp/plugins/base.py b/sleekxmpp/plugins/base.py index ec5ed10b..f08023ba 100644 --- a/sleekxmpp/plugins/base.py +++ b/sleekxmpp/plugins/base.py @@ -13,8 +13,9 @@ :license: MIT, see LICENSE for more details """ -import threading +import sys import logging +import threading log = logging.getLogger(__name__) @@ -77,17 +78,20 @@ def load_plugin(name, module=None): if not module: try: module = 'sleekxmpp.plugins.%s' % name - mod = __import__(module, fromlist=[str(name)]) + __import__(module) + mod = sys.modules[module] except: module = 'sleekxmpp.features.%s' % name - mod = __import__(module, fromlist=[str(name)]) + __import__(module) + mod = sys.modules[module] else: - mod = __import__(module, fromlist=[str(name)]) + __import__(module) + mod = sys.modules[module] # Add older style plugins to the registry. if hasattr(mod, name): plugin = getattr(mod, name) - if not hasattr(plugin, 'name'): + if hasattr(plugin, 'xep') or hasattr(plugin, 'rfc'): plugin.name = name # Mark the plugin as an older style plugin so # we can work around dependency issues. -- cgit v1.2.3