From 35acce6430f5bf1a91bb909e29266534c789c8f2 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 13 Apr 2009 10:02:20 +1000 Subject: [PATCH] The usage of ui_ prefix in the interfaces seems to make things a tad bit complicated when loading every interface. So _import_name needs to be a tad bit smarter. --- mitterlib/ui/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mitterlib/ui/__init__.py b/mitterlib/ui/__init__.py index 5597691..917ab82 100644 --- a/mitterlib/ui/__init__.py +++ b/mitterlib/ui/__init__.py @@ -36,7 +36,12 @@ def _import_name(module): """Based on the name of the module, return the proper "import" statement.""" (name, _) = os.path.splitext(module) - return 'mitterlib.ui.%s' % (name) + if name.startswith('ui_'): + mask = 'mitterlib.ui.%s' + else: + mask = 'mitterlib.ui.ui_%s' + + return mask % (name) class Interfaces(object): @@ -79,6 +84,7 @@ class Interfaces(object): # [we could be mean and use random.choice(self._interfaces)] import_name = self._interfaces[0] + _log.debug('Loading interface %s', import_name) module_name = _import_name(import_name) - module = __import__(module_name, fromlist[module_name]) + module = __import__(module_name, fromlist=[module_name]) return module.Interface(connection, self._options)