From: Brian Dolbec <dolsen@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Subject: Re: [gentoo-portage-dev] [PATCH] Use _SUBMODULE_PATH_MAP keys for option choices
Date: Wed, 7 Jan 2015 20:31:52 -0800 [thread overview]
Message-ID: <20150107203152.4ca06d3a.dolsen@gentoo.org> (raw)
In-Reply-To: <1420625296-13161-1-git-send-email-zmedico@gentoo.org>
On Wed, 7 Jan 2015 02:08:16 -0800
Zac Medico <zmedico@gentoo.org> wrote:
> 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@gentoo.org>
> ---
> 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 <dolsen>
prev parent reply other threads:[~2015-01-08 4:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-31 8:07 [gentoo-portage-dev] [PATCH] Add --sync-submodule <glsa|news|profiles> (534070) Zac Medico
2015-01-05 13:52 ` Alexander Berntsen
2015-01-07 4:53 ` Brian Dolbec
2015-01-07 9:31 ` Zac Medico
2015-01-07 10:08 ` [gentoo-portage-dev] [PATCH] Use _SUBMODULE_PATH_MAP keys for option choices Zac Medico
2015-01-08 4:31 ` Brian Dolbec [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150107203152.4ca06d3a.dolsen@gentoo.org \
--to=dolsen@gentoo.org \
--cc=gentoo-portage-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox