* [gentoo-commits] proj/portage:repoman commit in: pym/portage/
@ 2015-12-30 23:38 Brian Dolbec
0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2015-12-30 23:38 UTC (permalink / raw
To: gentoo-commits
commit: a26821f63c01005cb1e9509051fd44c7c2b08012
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 30 23:28:02 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Dec 30 23:28:02 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=a26821f6
portage/module.py: Fix bug where the module_spec module name was not being used
This only showed up when the module's target name (filename) was not the same as the
modules initialization name.
pym/portage/module.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pym/portage/module.py b/pym/portage/module.py
index 2277e7a..69050aa 100644
--- a/pym/portage/module.py
+++ b/pym/portage/module.py
@@ -46,7 +46,7 @@ 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, self.name])
+ kid['module_name'] = '.'.join([mod_name, kidname])
kid['is_imported'] = False
self.kids[kidname] = kid
self.kids_names.append(kidname)
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/portage/
2016-04-29 23:16 [gentoo-commits] proj/portage:master " Brian Dolbec
@ 2016-05-03 6:11 ` Brian Dolbec
0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2016-05-03 6:11 UTC (permalink / raw
To: gentoo-commits
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)
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/portage/
2016-04-30 0:12 [gentoo-commits] proj/portage:master " Brian Dolbec
@ 2016-05-03 6:11 ` Brian Dolbec
0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2016-05-03 6:11 UTC (permalink / raw
To: gentoo-commits
commit: 83baf60851c023fd985eab8a119f52a781c9be74
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 30 00:11:35 2016 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Apr 30 00:11:35 2016 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=83baf608
portage/modules.py: Change warnings output to writemsg()
Add the missing attribute and filepath to the output for best clarity, bug reporting.
pym/portage/module.py | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/pym/portage/module.py b/pym/portage/module.py
index b7967ba..f9828a5 100644
--- a/pym/portage/module.py
+++ b/pym/portage/module.py
@@ -4,12 +4,11 @@
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 _
+from portage.util import writemsg
class InvalidModuleName(PortageException):
@@ -53,10 +52,10 @@ class Module(object):
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)
+ msg = ("%s module's module_spec is old, missing attribute: "
+ "'sourcefile'. Backward compatibility may be "
+ "removed in the future.\nFile: %s\n")
+ writemsg(_(msg) % (self.name, self._module.__file__))
kid['is_imported'] = False
self.kids[kidname] = kid
self.kids_names.append(kidname)
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/portage/
@ 2017-06-27 20:06 Brian Dolbec
0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2017-06-27 20:06 UTC (permalink / raw
To: gentoo-commits
commit: ff2c1d017cf2f8aa6a8eba4e0495089c5d73f277
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 15 07:25:23 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jun 15 17:05:30 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=ff2c1d01
const: Remove unused MANIFEST1_REQUIRED_HASH
The MANIFEST1_REQUIRED_HASH constant is not used anywhere, so it should
be possible to remove it safely.
Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>
pym/portage/const.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/pym/portage/const.py b/pym/portage/const.py
index 7e415ba9c..052d4ca2f 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -206,7 +206,6 @@ EAPI = 6
HASHING_BLOCKSIZE = 32768
MANIFEST1_HASH_FUNCTIONS = ("MD5", "SHA256", "RMD160")
-MANIFEST1_REQUIRED_HASH = "MD5"
# Past events:
#
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/portage/
@ 2017-06-27 20:06 Brian Dolbec
0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2017-06-27 20:06 UTC (permalink / raw
To: gentoo-commits
commit: e6abcc0b7cbdca481862a5c7cca946c01c471ffb
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 15 07:27:47 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jun 15 17:15:05 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e6abcc0b
const: Change the MANIFEST2_REQUIRED_HASH to SHA512
Following the plan established in GLEP 59, we're long overdue
deprecating SHA256. Since we have finally got rid of the last packages
lacking SHA512 checksums, we can proceed with that. In order to prepare
for it, however, we need to change the required hash to SHA512 and make
sure developers install the new Portage & repoman versions first.
Of course, a better course of action would be to kill
MANIFEST2_REQUIRED_HASH entirely and make Portage capable of dealing
with any hash set. However, that's a larger piece of work and it would
delay the immediate goal.
Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>
pym/portage/const.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pym/portage/const.py b/pym/portage/const.py
index 052d4ca2f..cbd2b6042 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -234,7 +234,7 @@ MANIFEST2_HASH_FUNCTIONS = ("SHA256", "SHA512", "WHIRLPOOL",
"BLAKE2B", "BLAKE2S", "SHA3_256", "SHA3_512",
"STREEBOG256", "STREEBOG512")
MANIFEST2_HASH_DEFAULTS = frozenset(["SHA256", "SHA512", "WHIRLPOOL"])
-MANIFEST2_REQUIRED_HASH = "SHA256"
+MANIFEST2_REQUIRED_HASH = "SHA512"
MANIFEST2_IDENTIFIERS = ("AUX", "MISC", "DIST", "EBUILD")
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/portage/
@ 2017-07-10 17:52 Brian Dolbec
0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2017-07-10 17:52 UTC (permalink / raw
To: gentoo-commits
commit: a9da39a81f0469ab7e2086b3225c45ad5def25a1
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 17:50:19 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=a9da39a8
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
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/portage/
@ 2017-07-10 22:31 Brian Dolbec
0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2017-07-10 22:31 UTC (permalink / raw
To: gentoo-commits
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
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/portage/
@ 2017-08-17 1:59 Brian Dolbec
0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2017-08-17 1:59 UTC (permalink / raw
To: gentoo-commits
commit: 927465611c1e01c945d0d131325f7e6d3eebbcc2
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 17 01:50:21 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Aug 17 01:57:47 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=92746561
module.py: Extend the module loader for API version checking
If provided with an iterable of compatibility versions, The controller
will check the plugin modules module_spec 'version' variable is
compatible with the base application.
pym/portage/module.py | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/pym/portage/module.py b/pym/portage/module.py
index 00f322387..f5116b6f5 100644
--- a/pym/portage/module.py
+++ b/pym/portage/module.py
@@ -15,6 +15,10 @@ class InvalidModuleName(PortageException):
"""An invalid or unknown module name."""
+class ModuleVersionError(PortageException):
+ '''An incompatible module version'''
+
+
class Module(object):
"""Class to define and hold our plug-in module
@@ -87,16 +91,17 @@ class Modules(object):
@param namepath: Python import path to the "modules" directory
"""
- def __init__(self, path, namepath):
+ def __init__(self, path, namepath, compat_versions=None):
self._module_path = path
self._namepath = namepath
+ self.compat_versions = compat_versions
self.parents = []
self._modules = self._get_all_modules()
self.modules = ProtectedDict(self._modules)
self.module_names = sorted(self._modules)
def _get_all_modules(self):
- """scans the emaint modules dir for loadable modules
+ """scans the _module_path dir for loadable modules
@rtype: dictionary of module_plugins
"""
@@ -117,6 +122,7 @@ class Modules(object):
kids = {}
for entry in importables:
new_module = Module(entry, self._namepath)
+ self._check_compat(new_module)
for module_name in new_module.kids:
kid = new_module.kids[module_name]
kid['parent'] = new_module
@@ -211,6 +217,8 @@ class Modules(object):
@type modname: string
@param modname: the module class name
+ @type var: string
+ @param var: the base level variable to return
@type dictionary
@return: the modules class exported options descriptions
"""
@@ -220,3 +228,13 @@ class Modules(object):
raise InvalidModuleName(
"Module name '%s' was invalid or not found" % modname)
return value
+
+ def _check_compat(self, module):
+ if self.compat_versions:
+ if not module.module_spec['version'] in self.compat_versions:
+ raise ModuleVersionError(
+ "Error loading '%s' plugin module: %s, version: %s\n"
+ "Module is not compatible with the current application version\n"
+ "Compatible module API versions are: %s"
+ % (self._namepath, module.module_spec['name'],
+ module.module_spec['version'], self.compat_versions))
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/portage/
@ 2017-09-11 21:43 Brian Dolbec
0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2017-09-11 21:43 UTC (permalink / raw
To: gentoo-commits
commit: 4cdcaf7ffc9a03e5113f76e7f7860275615166c5
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 17 01:50:21 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Sep 11 16:13:17 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=4cdcaf7f
module.py: Extend the module loader for API version checking
If provided with an iterable of compatibility versions, The controller
will check the plugin modules module_spec 'version' variable is
compatible with the base application.
pym/portage/module.py | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/pym/portage/module.py b/pym/portage/module.py
index 00f322387..f5116b6f5 100644
--- a/pym/portage/module.py
+++ b/pym/portage/module.py
@@ -15,6 +15,10 @@ class InvalidModuleName(PortageException):
"""An invalid or unknown module name."""
+class ModuleVersionError(PortageException):
+ '''An incompatible module version'''
+
+
class Module(object):
"""Class to define and hold our plug-in module
@@ -87,16 +91,17 @@ class Modules(object):
@param namepath: Python import path to the "modules" directory
"""
- def __init__(self, path, namepath):
+ def __init__(self, path, namepath, compat_versions=None):
self._module_path = path
self._namepath = namepath
+ self.compat_versions = compat_versions
self.parents = []
self._modules = self._get_all_modules()
self.modules = ProtectedDict(self._modules)
self.module_names = sorted(self._modules)
def _get_all_modules(self):
- """scans the emaint modules dir for loadable modules
+ """scans the _module_path dir for loadable modules
@rtype: dictionary of module_plugins
"""
@@ -117,6 +122,7 @@ class Modules(object):
kids = {}
for entry in importables:
new_module = Module(entry, self._namepath)
+ self._check_compat(new_module)
for module_name in new_module.kids:
kid = new_module.kids[module_name]
kid['parent'] = new_module
@@ -211,6 +217,8 @@ class Modules(object):
@type modname: string
@param modname: the module class name
+ @type var: string
+ @param var: the base level variable to return
@type dictionary
@return: the modules class exported options descriptions
"""
@@ -220,3 +228,13 @@ class Modules(object):
raise InvalidModuleName(
"Module name '%s' was invalid or not found" % modname)
return value
+
+ def _check_compat(self, module):
+ if self.compat_versions:
+ if not module.module_spec['version'] in self.compat_versions:
+ raise ModuleVersionError(
+ "Error loading '%s' plugin module: %s, version: %s\n"
+ "Module is not compatible with the current application version\n"
+ "Compatible module API versions are: %s"
+ % (self._namepath, module.module_spec['name'],
+ module.module_spec['version'], self.compat_versions))
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/portage/
@ 2017-11-26 17:46 Brian Dolbec
0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2017-11-26 17:46 UTC (permalink / raw
To: gentoo-commits
commit: 94b1d9fd4b903ee2e6c1f6e34275d6b3df6a7bf3
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 17 01:50:21 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Nov 26 17:32:21 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=94b1d9fd
module.py: Extend the module loader for API version checking
If provided with an iterable of compatibility versions, The controller
will check the plugin modules module_spec 'version' variable is
compatible with the base application.
pym/portage/module.py | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/pym/portage/module.py b/pym/portage/module.py
index 00f322387..f5116b6f5 100644
--- a/pym/portage/module.py
+++ b/pym/portage/module.py
@@ -15,6 +15,10 @@ class InvalidModuleName(PortageException):
"""An invalid or unknown module name."""
+class ModuleVersionError(PortageException):
+ '''An incompatible module version'''
+
+
class Module(object):
"""Class to define and hold our plug-in module
@@ -87,16 +91,17 @@ class Modules(object):
@param namepath: Python import path to the "modules" directory
"""
- def __init__(self, path, namepath):
+ def __init__(self, path, namepath, compat_versions=None):
self._module_path = path
self._namepath = namepath
+ self.compat_versions = compat_versions
self.parents = []
self._modules = self._get_all_modules()
self.modules = ProtectedDict(self._modules)
self.module_names = sorted(self._modules)
def _get_all_modules(self):
- """scans the emaint modules dir for loadable modules
+ """scans the _module_path dir for loadable modules
@rtype: dictionary of module_plugins
"""
@@ -117,6 +122,7 @@ class Modules(object):
kids = {}
for entry in importables:
new_module = Module(entry, self._namepath)
+ self._check_compat(new_module)
for module_name in new_module.kids:
kid = new_module.kids[module_name]
kid['parent'] = new_module
@@ -211,6 +217,8 @@ class Modules(object):
@type modname: string
@param modname: the module class name
+ @type var: string
+ @param var: the base level variable to return
@type dictionary
@return: the modules class exported options descriptions
"""
@@ -220,3 +228,13 @@ class Modules(object):
raise InvalidModuleName(
"Module name '%s' was invalid or not found" % modname)
return value
+
+ def _check_compat(self, module):
+ if self.compat_versions:
+ if not module.module_spec['version'] in self.compat_versions:
+ raise ModuleVersionError(
+ "Error loading '%s' plugin module: %s, version: %s\n"
+ "Module is not compatible with the current application version\n"
+ "Compatible module API versions are: %s"
+ % (self._namepath, module.module_spec['name'],
+ module.module_spec['version'], self.compat_versions))
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/portage/
@ 2017-12-05 18:32 Brian Dolbec
0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2017-12-05 18:32 UTC (permalink / raw
To: gentoo-commits
commit: 687f87be15129b06e761c996478e8ea4a7b6fc82
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 17 01:50:21 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 5 18:24:49 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=687f87be
module.py: Extend the module loader for API version checking
If provided with an iterable of compatibility versions, The controller
will check the plugin modules module_spec 'version' variable is
compatible with the base application.
pym/portage/module.py | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/pym/portage/module.py b/pym/portage/module.py
index 00f322387..f5116b6f5 100644
--- a/pym/portage/module.py
+++ b/pym/portage/module.py
@@ -15,6 +15,10 @@ class InvalidModuleName(PortageException):
"""An invalid or unknown module name."""
+class ModuleVersionError(PortageException):
+ '''An incompatible module version'''
+
+
class Module(object):
"""Class to define and hold our plug-in module
@@ -87,16 +91,17 @@ class Modules(object):
@param namepath: Python import path to the "modules" directory
"""
- def __init__(self, path, namepath):
+ def __init__(self, path, namepath, compat_versions=None):
self._module_path = path
self._namepath = namepath
+ self.compat_versions = compat_versions
self.parents = []
self._modules = self._get_all_modules()
self.modules = ProtectedDict(self._modules)
self.module_names = sorted(self._modules)
def _get_all_modules(self):
- """scans the emaint modules dir for loadable modules
+ """scans the _module_path dir for loadable modules
@rtype: dictionary of module_plugins
"""
@@ -117,6 +122,7 @@ class Modules(object):
kids = {}
for entry in importables:
new_module = Module(entry, self._namepath)
+ self._check_compat(new_module)
for module_name in new_module.kids:
kid = new_module.kids[module_name]
kid['parent'] = new_module
@@ -211,6 +217,8 @@ class Modules(object):
@type modname: string
@param modname: the module class name
+ @type var: string
+ @param var: the base level variable to return
@type dictionary
@return: the modules class exported options descriptions
"""
@@ -220,3 +228,13 @@ class Modules(object):
raise InvalidModuleName(
"Module name '%s' was invalid or not found" % modname)
return value
+
+ def _check_compat(self, module):
+ if self.compat_versions:
+ if not module.module_spec['version'] in self.compat_versions:
+ raise ModuleVersionError(
+ "Error loading '%s' plugin module: %s, version: %s\n"
+ "Module is not compatible with the current application version\n"
+ "Compatible module API versions are: %s"
+ % (self._namepath, module.module_spec['name'],
+ module.module_spec['version'], self.compat_versions))
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/portage/
@ 2017-12-06 0:16 Brian Dolbec
0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2017-12-06 0:16 UTC (permalink / raw
To: gentoo-commits
commit: 12f83daec005e3004a249b2e2ad600e47ae2c496
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 17 01:50:21 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Dec 6 00:13:28 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=12f83dae
module.py: Extend the module loader for API version checking
If provided with an iterable of compatibility versions, The controller
will check the plugin modules module_spec 'version' variable is
compatible with the base application.
pym/portage/module.py | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/pym/portage/module.py b/pym/portage/module.py
index c79e65518..bd7c94d4e 100644
--- a/pym/portage/module.py
+++ b/pym/portage/module.py
@@ -15,6 +15,10 @@ class InvalidModuleName(PortageException):
"""An invalid or unknown module name."""
+class ModuleVersionError(PortageException):
+ '''An incompatible module version'''
+
+
class Module(object):
"""Class to define and hold our plug-in module
@@ -87,16 +91,17 @@ class Modules(object):
@param namepath: Python import path to the "modules" directory
"""
- def __init__(self, path, namepath):
+ def __init__(self, path, namepath, compat_versions=None):
self._module_path = path
self._namepath = namepath
+ self.compat_versions = compat_versions
self.parents = []
self._modules = self._get_all_modules()
self.modules = ProtectedDict(self._modules)
self.module_names = sorted(self._modules)
def _get_all_modules(self):
- """scans the emaint modules dir for loadable modules
+ """scans the _module_path dir for loadable modules
@rtype: dictionary of module_plugins
"""
@@ -117,6 +122,7 @@ class Modules(object):
kids = {}
for entry in importables:
new_module = Module(entry, self._namepath)
+ self._check_compat(new_module)
for module_name in new_module.kids:
kid = new_module.kids[module_name]
kid['parent'] = new_module
@@ -211,6 +217,8 @@ class Modules(object):
@type modname: string
@param modname: the module class name
+ @type var: string
+ @param var: the base level variable to return
@type dictionary
@return: the modules class exported options descriptions
"""
@@ -220,3 +228,13 @@ class Modules(object):
raise InvalidModuleName(
"Module name '%s' is invalid or not found" % modname)
return value
+
+ def _check_compat(self, module):
+ if self.compat_versions:
+ if not module.module_spec['version'] in self.compat_versions:
+ raise ModuleVersionError(
+ "Error loading '%s' plugin module: %s, version: %s\n"
+ "Module is not compatible with the current application version\n"
+ "Compatible module API versions are: %s"
+ % (self._namepath, module.module_spec['name'],
+ module.module_spec['version'], self.compat_versions))
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/portage/
@ 2018-03-29 21:35 Brian Dolbec
0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2018-03-29 21:35 UTC (permalink / raw
To: gentoo-commits
commit: 1dd08a1ed5ad1b848a30f29f93a3b051c8bf95c4
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 17 01:50:21 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Mar 29 20:43:40 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=1dd08a1e
module.py: Extend the module loader for API version checking
If provided with an iterable of compatibility versions, The controller
will check the plugin modules module_spec 'version' variable is
compatible with the base application.
pym/portage/module.py | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/pym/portage/module.py b/pym/portage/module.py
index c79e65518..bd7c94d4e 100644
--- a/pym/portage/module.py
+++ b/pym/portage/module.py
@@ -15,6 +15,10 @@ class InvalidModuleName(PortageException):
"""An invalid or unknown module name."""
+class ModuleVersionError(PortageException):
+ '''An incompatible module version'''
+
+
class Module(object):
"""Class to define and hold our plug-in module
@@ -87,16 +91,17 @@ class Modules(object):
@param namepath: Python import path to the "modules" directory
"""
- def __init__(self, path, namepath):
+ def __init__(self, path, namepath, compat_versions=None):
self._module_path = path
self._namepath = namepath
+ self.compat_versions = compat_versions
self.parents = []
self._modules = self._get_all_modules()
self.modules = ProtectedDict(self._modules)
self.module_names = sorted(self._modules)
def _get_all_modules(self):
- """scans the emaint modules dir for loadable modules
+ """scans the _module_path dir for loadable modules
@rtype: dictionary of module_plugins
"""
@@ -117,6 +122,7 @@ class Modules(object):
kids = {}
for entry in importables:
new_module = Module(entry, self._namepath)
+ self._check_compat(new_module)
for module_name in new_module.kids:
kid = new_module.kids[module_name]
kid['parent'] = new_module
@@ -211,6 +217,8 @@ class Modules(object):
@type modname: string
@param modname: the module class name
+ @type var: string
+ @param var: the base level variable to return
@type dictionary
@return: the modules class exported options descriptions
"""
@@ -220,3 +228,13 @@ class Modules(object):
raise InvalidModuleName(
"Module name '%s' is invalid or not found" % modname)
return value
+
+ def _check_compat(self, module):
+ if self.compat_versions:
+ if not module.module_spec['version'] in self.compat_versions:
+ raise ModuleVersionError(
+ "Error loading '%s' plugin module: %s, version: %s\n"
+ "Module is not compatible with the current application version\n"
+ "Compatible module API versions are: %s"
+ % (self._namepath, module.module_spec['name'],
+ module.module_spec['version'], self.compat_versions))
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/portage/
@ 2018-03-30 0:48 Brian Dolbec
0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2018-03-30 0:48 UTC (permalink / raw
To: gentoo-commits
commit: 4333abb4c54ba81b1622c3cd951ae8aacf8e4560
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 17 01:50:21 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Mar 30 00:43:46 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=4333abb4
module.py: Extend the module loader for API version checking
If provided with an iterable of compatibility versions, The controller
will check the plugin modules module_spec 'version' variable is
compatible with the base application.
pym/portage/module.py | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/pym/portage/module.py b/pym/portage/module.py
index c79e65518..bd7c94d4e 100644
--- a/pym/portage/module.py
+++ b/pym/portage/module.py
@@ -15,6 +15,10 @@ class InvalidModuleName(PortageException):
"""An invalid or unknown module name."""
+class ModuleVersionError(PortageException):
+ '''An incompatible module version'''
+
+
class Module(object):
"""Class to define and hold our plug-in module
@@ -87,16 +91,17 @@ class Modules(object):
@param namepath: Python import path to the "modules" directory
"""
- def __init__(self, path, namepath):
+ def __init__(self, path, namepath, compat_versions=None):
self._module_path = path
self._namepath = namepath
+ self.compat_versions = compat_versions
self.parents = []
self._modules = self._get_all_modules()
self.modules = ProtectedDict(self._modules)
self.module_names = sorted(self._modules)
def _get_all_modules(self):
- """scans the emaint modules dir for loadable modules
+ """scans the _module_path dir for loadable modules
@rtype: dictionary of module_plugins
"""
@@ -117,6 +122,7 @@ class Modules(object):
kids = {}
for entry in importables:
new_module = Module(entry, self._namepath)
+ self._check_compat(new_module)
for module_name in new_module.kids:
kid = new_module.kids[module_name]
kid['parent'] = new_module
@@ -211,6 +217,8 @@ class Modules(object):
@type modname: string
@param modname: the module class name
+ @type var: string
+ @param var: the base level variable to return
@type dictionary
@return: the modules class exported options descriptions
"""
@@ -220,3 +228,13 @@ class Modules(object):
raise InvalidModuleName(
"Module name '%s' is invalid or not found" % modname)
return value
+
+ def _check_compat(self, module):
+ if self.compat_versions:
+ if not module.module_spec['version'] in self.compat_versions:
+ raise ModuleVersionError(
+ "Error loading '%s' plugin module: %s, version: %s\n"
+ "Module is not compatible with the current application version\n"
+ "Compatible module API versions are: %s"
+ % (self._namepath, module.module_spec['name'],
+ module.module_spec['version'], self.compat_versions))
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [gentoo-commits] proj/portage:repoman commit in: pym/portage/
@ 2018-03-30 5:20 Zac Medico
0 siblings, 0 replies; 15+ messages in thread
From: Zac Medico @ 2018-03-30 5:20 UTC (permalink / raw
To: gentoo-commits
commit: 3bffbc6150be9ee81d47547cbff113a8d45edb6d
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 17 01:50:21 2017 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Mar 30 03:51:20 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=3bffbc61
module.py: Extend the module loader for API version checking
If provided with an iterable of compatibility versions, The controller
will check the plugin modules module_spec 'version' variable is
compatible with the base application.
pym/portage/module.py | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/pym/portage/module.py b/pym/portage/module.py
index c79e65518..bd7c94d4e 100644
--- a/pym/portage/module.py
+++ b/pym/portage/module.py
@@ -15,6 +15,10 @@ class InvalidModuleName(PortageException):
"""An invalid or unknown module name."""
+class ModuleVersionError(PortageException):
+ '''An incompatible module version'''
+
+
class Module(object):
"""Class to define and hold our plug-in module
@@ -87,16 +91,17 @@ class Modules(object):
@param namepath: Python import path to the "modules" directory
"""
- def __init__(self, path, namepath):
+ def __init__(self, path, namepath, compat_versions=None):
self._module_path = path
self._namepath = namepath
+ self.compat_versions = compat_versions
self.parents = []
self._modules = self._get_all_modules()
self.modules = ProtectedDict(self._modules)
self.module_names = sorted(self._modules)
def _get_all_modules(self):
- """scans the emaint modules dir for loadable modules
+ """scans the _module_path dir for loadable modules
@rtype: dictionary of module_plugins
"""
@@ -117,6 +122,7 @@ class Modules(object):
kids = {}
for entry in importables:
new_module = Module(entry, self._namepath)
+ self._check_compat(new_module)
for module_name in new_module.kids:
kid = new_module.kids[module_name]
kid['parent'] = new_module
@@ -211,6 +217,8 @@ class Modules(object):
@type modname: string
@param modname: the module class name
+ @type var: string
+ @param var: the base level variable to return
@type dictionary
@return: the modules class exported options descriptions
"""
@@ -220,3 +228,13 @@ class Modules(object):
raise InvalidModuleName(
"Module name '%s' is invalid or not found" % modname)
return value
+
+ def _check_compat(self, module):
+ if self.compat_versions:
+ if not module.module_spec['version'] in self.compat_versions:
+ raise ModuleVersionError(
+ "Error loading '%s' plugin module: %s, version: %s\n"
+ "Module is not compatible with the current application version\n"
+ "Compatible module API versions are: %s"
+ % (self._namepath, module.module_spec['name'],
+ module.module_spec['version'], self.compat_versions))
^ permalink raw reply related [flat|nested] 15+ messages in thread
end of thread, other threads:[~2018-03-30 5:21 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-29 21:35 [gentoo-commits] proj/portage:repoman commit in: pym/portage/ Brian Dolbec
-- strict thread matches above, loose matches on Subject: below --
2018-03-30 5:20 Zac Medico
2018-03-30 0:48 Brian Dolbec
2017-12-06 0:16 Brian Dolbec
2017-12-05 18:32 Brian Dolbec
2017-11-26 17:46 Brian Dolbec
2017-09-11 21:43 Brian Dolbec
2017-08-17 1:59 Brian Dolbec
2017-07-10 22:31 Brian Dolbec
2017-07-10 17:52 Brian Dolbec
2017-06-27 20:06 Brian Dolbec
2017-06-27 20:06 Brian Dolbec
2016-04-30 0:12 [gentoo-commits] proj/portage:master " Brian Dolbec
2016-05-03 6:11 ` [gentoo-commits] proj/portage:repoman " Brian Dolbec
2016-04-29 23:16 [gentoo-commits] proj/portage:master " Brian Dolbec
2016-05-03 6:11 ` [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-12-30 23:38 Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox