Browse Source

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.

master
Julio Biason 16 years ago
parent
commit
35acce6430
  1. 10
      mitterlib/ui/__init__.py

10
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)

Loading…
Cancel
Save