diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2014-09-05 19:33:28 +0200 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2014-09-05 19:33:28 +0200 |
commit | 5cd93997d63b04a0de5221b53d18ff7d050140cc (patch) | |
tree | 6fd0141a3353f269c8c81a3d559218ca0b442a65 | |
parent | 45f915dc77d8f0631dbddc4c809b0ff479414d89 (diff) | |
download | clufter-5cd93997d63b04a0de5221b53d18ff7d050140cc.tar.gz clufter-5cd93997d63b04a0de5221b53d18ff7d050140cc.tar.xz clufter-5cd93997d63b04a0de5221b53d18ff7d050140cc.zip |
plugin_registry: simplify singular-plural arg handling
...using primitives from utils.py
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rw-r--r-- | plugin_registry.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/plugin_registry.py b/plugin_registry.py index df5ce08..f17de96 100644 --- a/plugin_registry.py +++ b/plugin_registry.py @@ -12,7 +12,11 @@ from os.path import abspath, dirname, join, splitext from contextlib import contextmanager from sys import modules -from .utils import classproperty, hybridproperty, tuplist +from .utils import args2tuple, \ + args2sgpl, \ + classproperty, \ + hybridproperty, \ + tuplist from .utils_prog import ProtectedDict, cli_decor log = logging.getLogger(__name__) @@ -147,14 +151,11 @@ class PluginRegistry(type): Context is a pair `(path, list_of_per_path_tracked_plugins_so_far)`. """ - if not isinstance(paths, (list, tuple)): - if paths is None: - return # explictly asked not to use even implicit path - paths = (paths, ) - + if paths is None: + return # explictly asked not to use even implicit path # inject implicit one implicit = join(dirname(abspath(__file__)), registry.__name__) - paths = (lambda *x: x)(implicit, *paths) + paths = args2tuple(implicit, *args2sgpl(paths)) for path in paths: with registry._path(path) as context: |