diff options
author | Lance Stout <lancestout@gmail.com> | 2012-03-12 19:00:32 -0700 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2012-03-12 19:32:20 -0700 |
commit | cabf27424fca40883d301bba09fc854abff6de77 (patch) | |
tree | d393a3d603d0905a88d239c03390a18cdea761f9 /sleekxmpp/plugins/base.py | |
parent | 162e955bd6200e4c9ca22e677adec3c30aec173e (diff) | |
download | slixmpp-cabf27424fca40883d301bba09fc854abff6de77.tar.gz slixmpp-cabf27424fca40883d301bba09fc854abff6de77.tar.bz2 slixmpp-cabf27424fca40883d301bba09fc854abff6de77.tar.xz slixmpp-cabf27424fca40883d301bba09fc854abff6de77.zip |
Cleanup plugin import logic.
Checking for a 'xep' or 'rfc' attribute is more reliable
for detecting an old style plugin than 'name'.
Diffstat (limited to 'sleekxmpp/plugins/base.py')
-rw-r--r-- | sleekxmpp/plugins/base.py | 14 |
1 files changed, 9 insertions, 5 deletions
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. |