aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Dolbec <dolsen@gentoo.org>2016-05-10 15:12:02 -0700
committerBrian Dolbec <dolsen@gentoo.org>2016-05-10 15:12:02 -0700
commit90fe6724d0a8d1ebfe6443dee118432e20432b8b (patch)
tree7e052a5e2a96a68274c5c684448de16b75abf88c
parentBumps version number to 2.4.1 (diff)
downloadlayman-90fe6724d0a8d1ebfe6443dee118432e20432b8b.tar.gz
layman-90fe6724d0a8d1ebfe6443dee118432e20432b8b.tar.bz2
layman-90fe6724d0a8d1ebfe6443dee118432e20432b8b.zip
layman/module.py: Fix commit 63808ef00f94 mis-applied 'sourcefile' attribute changes
It was not looking for the 'sourcefile' attribute first, then falling back to the kidname for backward compatibility. It was incorrectly looking for an ImportError, instead of a 'sourcefile' KeyError. The filepath of the affected file for the error message had an extra leading '_'. Add the module name to the warning message.
-rw-r--r--layman/module.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/layman/module.py b/layman/module.py
index 08bcbc2..092418f 100644
--- a/layman/module.py
+++ b/layman/module.py
@@ -49,13 +49,14 @@ class Module(object):
kid = self.module_spec['provides'][submodule]
kidname = kid['name']
try:
+ kid['module_name'] = '.'.join([mod_name, kid['sourcefile']])
+ except KeyError:
kid['module_name'] = '.'.join([mod_name, kidname])
- except ImportError:
- kid['module_name'] = '.'.join([mod_name, self.name])
- f = self.__module.__file__
- msg = 'Module.__initialize(); module spec is old, missing '\
+ f = self._module.__file__
+ msg = 'Module.__initialize(); %(module)s module spec is old, missing '\
'attribute: \'sourcefile\'.\nBackward compatibility '\
- 'may be removed in the future.\nFile: %(f)s' % {'f': f}
+ 'may be removed in the future.\nFile: %(f)s' % {
+ 'module': self.name, 'f': f}
self.output.warn(msg)
kid['is_imported'] = False
self.kids[kidname] = kid