commit: b75a834d421fecc1a3962c047cce9f110bf7da70 Author: Zac Medico <zmedico <AT> gentoo <DOT> org> AuthorDate: Wed Jan 7 10:06:10 2015 +0000 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> CommitDate: Thu Jan 8 07:06:21 2015 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b75a834d
Use _SUBMODULE_PATH_MAP keys for option choices Fix commit c8a850685232b938cf0896fc2d80e72d57edad17 to re-use the keys from _SUBMODULE_PATH_MAP for option choices. Fixes: c8a850685232 ("Add --sync-submodule <glsa|news|profiles> (534070)") Suggested-by: Brian Dolbec <dolsen <AT> gentoo.org> Acked-by: Brian Dolbec <dolsen <AT> gentoo.org> --- pym/_emerge/main.py | 3 ++- pym/portage/emaint/modules/sync/__init__.py | 4 +++- pym/portage/sync/__init__.py | 9 ++++++++- pym/portage/sync/syncbase.py | 7 +------ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index 93c1a15..3fcfcbf 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -20,6 +20,7 @@ portage.proxy.lazyimport.lazyimport(globals(), ) from portage import os from portage.util._argparse import ArgumentParser +from portage.sync import _SUBMODULE_PATH_MAP if sys.hexversion >= 0x3000000: long = int @@ -636,7 +637,7 @@ def parse_opts(tmpcmdline, silent=False): "--sync-submodule": { "help" : ("Restrict sync to the specified submodule(s)." " (--sync action only)"), - "choices" : ("glsa", "news", "profiles"), + "choices" : tuple(_SUBMODULE_PATH_MAP), "action" : "append", }, diff --git a/pym/portage/emaint/modules/sync/__init__.py b/pym/portage/emaint/modules/sync/__init__.py index 620861f..2fc8d34 100644 --- a/pym/portage/emaint/modules/sync/__init__.py +++ b/pym/portage/emaint/modules/sync/__init__.py @@ -1,6 +1,8 @@ # Copyright 2014-2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +from ....sync import _SUBMODULE_PATH_MAP + doc = """Check repos.conf settings and sync repositories.""" __doc__ = doc[:] @@ -43,7 +45,7 @@ module_spec = { "long": "--sync-submodule", "help": ("(sync module only): Restrict sync " "to the specified submodule(s)"), - "choices": ("glsa", "news", "profiles"), + "choices": tuple(_SUBMODULE_PATH_MAP), "action": "append", "dest": "sync_submodule", }, diff --git a/pym/portage/sync/__init__.py b/pym/portage/sync/__init__.py index 0f6c566..51bf051 100644 --- a/pym/portage/sync/__init__.py +++ b/pym/portage/sync/__init__.py @@ -1,12 +1,19 @@ -# Copyright 2014 Gentoo Foundation +# Copyright 2014-2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import os +from portage import OrderedDict from portage.module import Modules from portage.sync.controller import SyncManager from portage.sync.config_checks import check_type +_SUBMODULE_PATH_MAP = OrderedDict([ + ('glsa', 'metadata/glsa'), + ('news', 'metadata/news'), + ('profiles', 'profiles'), +]) + path = os.path.join(os.path.dirname(__file__), "modules") # initial development debug info #print("module path:", path) diff --git a/pym/portage/sync/syncbase.py b/pym/portage/sync/syncbase.py index 9506616..04db2d0 100644 --- a/pym/portage/sync/syncbase.py +++ b/pym/portage/sync/syncbase.py @@ -11,12 +11,7 @@ import os import portage from portage.util import writemsg_level - -_SUBMODULE_PATH_MAP = { - 'glsa': 'metadata/glsa', - 'news': 'metadata/news', - 'profiles': 'profiles', -} +from . import _SUBMODULE_PATH_MAP class SyncBase(object): '''Base Sync class for subclassing'''