From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 1A103138A1A for ; Wed, 7 Jan 2015 10:09:03 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 37D3EE0835; Wed, 7 Jan 2015 10:09:00 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B7C23E082B for ; Wed, 7 Jan 2015 10:08:59 +0000 (UTC) Received: from localhost.localdomain (99.sub-70-209-195.myvzw.com [70.209.195.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: zmedico) by smtp.gentoo.org (Postfix) with ESMTPSA id ABC65340731; Wed, 7 Jan 2015 10:08:58 +0000 (UTC) From: Zac Medico To: gentoo-portage-dev@lists.gentoo.org Cc: Zac Medico Subject: [gentoo-portage-dev] [PATCH] Use _SUBMODULE_PATH_MAP keys for option choices Date: Wed, 7 Jan 2015 02:08:16 -0800 Message-Id: <1420625296-13161-1-git-send-email-zmedico@gentoo.org> X-Mailer: git-send-email 2.0.5 In-Reply-To: <54ACFCE6.8000104@gentoo.org> References: <54ACFCE6.8000104@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Archives-Salt: f4d6233c-973a-46b6-ab47-1a0db3d9103a X-Archives-Hash: a575cfa536fa35fbecf9e1514596da5b Fix commit c8a850685232b938cf0896fc2d80e72d57edad17 to re-use the keys from _SUBMODULE_PATH_MAP for option choices. Fixes: c8a850685232 ("Add --sync-submodule (534070)") Suggested-by: Brian Dolbec --- pym/_emerge/main.py | 3 ++- pym/portage/emaint/modules/sync/__init__.py | 4 +++- pym/portage/sync/__init__.py | 7 +++++++ pym/portage/sync/syncbase.py | 7 +------ 4 files changed, 13 insertions(+), 8 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..e01f993 100644 --- a/pym/portage/sync/__init__.py +++ b/pym/portage/sync/__init__.py @@ -3,10 +3,17 @@ 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''' -- 2.0.5