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 D7146138A1A for ; Thu, 8 Jan 2015 04:32:09 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DAB20E08E9; Thu, 8 Jan 2015 04:32:08 +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 17CB7E0858 for ; Thu, 8 Jan 2015 04:32:06 +0000 (UTC) Received: from big_daddy.dol-sen.ca (S010634bdfa9ecf80.vc.shawcable.net [96.49.31.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dolsen) by smtp.gentoo.org (Postfix) with ESMTPSA id A5BAE340756 for ; Thu, 8 Jan 2015 04:32:04 +0000 (UTC) Date: Wed, 7 Jan 2015 20:31:52 -0800 From: Brian Dolbec To: gentoo-portage-dev@lists.gentoo.org Subject: Re: [gentoo-portage-dev] [PATCH] Use _SUBMODULE_PATH_MAP keys for option choices Message-ID: <20150107203152.4ca06d3a.dolsen@gentoo.org> In-Reply-To: <1420625296-13161-1-git-send-email-zmedico@gentoo.org> References: <54ACFCE6.8000104@gentoo.org> <1420625296-13161-1-git-send-email-zmedico@gentoo.org> Organization: Gentoo 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 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archives-Salt: f6b8295b-819d-4d13-852c-061ef429ae55 X-Archives-Hash: 6d3ee9156cb88d820dbefec91f04d886 On Wed, 7 Jan 2015 02:08:16 -0800 Zac Medico wrote: > 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''' Yeah, that looks a lot better... It now needs only one edit point instead of the three it had before :D -- Brian Dolbec