commit: 75fbbcf58f244717712602a83765bcdc6f07ddcf
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 29 23:14:28 2016 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Apr 29 23:14:28 2016 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=75fbbcf5
portage/module.py: Restore backaward compatibilty for previous module_spec.
If the module_spec is missing the 'sourcefile' key and value it will fall back
to the previous
code. It will also print a warning message.
pym/portage/module.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/pym/portage/module.py b/pym/portage/module.py
index 1a10996..b7967ba 100644
--- a/pym/portage/module.py
+++ b/pym/portage/module.py
@@ -4,9 +4,12 @@
from __future__ import print_function
+import warnings
+
from portage import os
from portage.exception import PortageException
from portage.cache.mappings import ProtectedDict
+from portage.localization import _
class InvalidModuleName(PortageException):
@@ -46,7 +49,14 @@ class Module(object):
for submodule in self.module_spec['provides']:
kid = self.module_spec['provides'][submodule]
kidname = kid['name']
- kid['module_name'] = '.'.join([mod_name,
kid['sourcefile']])
+ try:
+ kid['module_name'] = '.'.join([mod_name,
kid['sourcefile']])
+ except KeyError:
+ kid['module_name'] = '.'.join([mod_name,
self.name])
+ warnings.warn(
+ _("%s module's module_spec is old and
needs updating. "
+ "Backward compatibility may be
removed in the future.")
+ % (self.name), UserWarning,
stacklevel=2)
kid['is_imported'] = False
self.kids[kidname] = kid
self.kids_names.append(kidname)