commit: 63a77a1790c357625d92a1a18693480ccfbb7cde
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 10 17:29:05 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Jul 10 22:29:33 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=63a77a17
portage/module.py: Add a generic get_spec()
This new function gets any arbitrary spec value.
The other get_* functions could be optimized to return the
get_spec result instead. This would reduce code duplication.
pym/portage/module.py | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/pym/portage/module.py b/pym/portage/module.py
index f9828a518..00f322387 100644
--- a/pym/portage/module.py
+++ b/pym/portage/module.py
@@ -205,3 +205,18 @@ class Modules(object):
raise InvalidModuleName(
"Module name '%s' was invalid or not found" %
modname)
return desc
+
+ def get_spec(self, modname, var):
+ """Retrieves the module class exported spec variable
+
+ @type modname: string
+ @param modname: the module class name
+ @type dictionary
+ @return: the modules class exported options descriptions
+ """
+ if modname and modname in self.module_names:
+ value = self._modules[modname].get(var, None)
+ else:
+ raise InvalidModuleName(
+ "Module name '%s' was invalid or not found" %
modname)
+ return value