Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH] Use _SUBMODULE_PATH_MAP keys for option choices
Date: Wed, 07 Jan 2015 10:09:03
Message-Id: 1420625296-13161-1-git-send-email-zmedico@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH] Add --sync-submodule (534070) by Zac Medico
1 Fix commit c8a850685232b938cf0896fc2d80e72d57edad17 to re-use the keys
2 from _SUBMODULE_PATH_MAP for option choices.
3
4 Fixes: c8a850685232 ("Add --sync-submodule <glsa|news|profiles> (534070)")
5 Suggested-by: Brian Dolbec <dolsen@g.o>
6 ---
7 pym/_emerge/main.py | 3 ++-
8 pym/portage/emaint/modules/sync/__init__.py | 4 +++-
9 pym/portage/sync/__init__.py | 7 +++++++
10 pym/portage/sync/syncbase.py | 7 +------
11 4 files changed, 13 insertions(+), 8 deletions(-)
12
13 diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
14 index 93c1a15..3fcfcbf 100644
15 --- a/pym/_emerge/main.py
16 +++ b/pym/_emerge/main.py
17 @@ -20,6 +20,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
18 )
19 from portage import os
20 from portage.util._argparse import ArgumentParser
21 +from portage.sync import _SUBMODULE_PATH_MAP
22
23 if sys.hexversion >= 0x3000000:
24 long = int
25 @@ -636,7 +637,7 @@ def parse_opts(tmpcmdline, silent=False):
26 "--sync-submodule": {
27 "help" : ("Restrict sync to the specified submodule(s)."
28 " (--sync action only)"),
29 - "choices" : ("glsa", "news", "profiles"),
30 + "choices" : tuple(_SUBMODULE_PATH_MAP),
31 "action" : "append",
32 },
33
34 diff --git a/pym/portage/emaint/modules/sync/__init__.py b/pym/portage/emaint/modules/sync/__init__.py
35 index 620861f..2fc8d34 100644
36 --- a/pym/portage/emaint/modules/sync/__init__.py
37 +++ b/pym/portage/emaint/modules/sync/__init__.py
38 @@ -1,6 +1,8 @@
39 # Copyright 2014-2015 Gentoo Foundation
40 # Distributed under the terms of the GNU General Public License v2
41
42 +from ....sync import _SUBMODULE_PATH_MAP
43 +
44 doc = """Check repos.conf settings and sync repositories."""
45 __doc__ = doc[:]
46
47 @@ -43,7 +45,7 @@ module_spec = {
48 "long": "--sync-submodule",
49 "help": ("(sync module only): Restrict sync "
50 "to the specified submodule(s)"),
51 - "choices": ("glsa", "news", "profiles"),
52 + "choices": tuple(_SUBMODULE_PATH_MAP),
53 "action": "append",
54 "dest": "sync_submodule",
55 },
56 diff --git a/pym/portage/sync/__init__.py b/pym/portage/sync/__init__.py
57 index 0f6c566..e01f993 100644
58 --- a/pym/portage/sync/__init__.py
59 +++ b/pym/portage/sync/__init__.py
60 @@ -3,10 +3,17 @@
61
62 import os
63
64 +from portage import OrderedDict
65 from portage.module import Modules
66 from portage.sync.controller import SyncManager
67 from portage.sync.config_checks import check_type
68
69 +_SUBMODULE_PATH_MAP = OrderedDict([
70 + ('glsa', 'metadata/glsa'),
71 + ('news', 'metadata/news'),
72 + ('profiles', 'profiles'),
73 +])
74 +
75 path = os.path.join(os.path.dirname(__file__), "modules")
76 # initial development debug info
77 #print("module path:", path)
78 diff --git a/pym/portage/sync/syncbase.py b/pym/portage/sync/syncbase.py
79 index 9506616..04db2d0 100644
80 --- a/pym/portage/sync/syncbase.py
81 +++ b/pym/portage/sync/syncbase.py
82 @@ -11,12 +11,7 @@ import os
83
84 import portage
85 from portage.util import writemsg_level
86 -
87 -_SUBMODULE_PATH_MAP = {
88 - 'glsa': 'metadata/glsa',
89 - 'news': 'metadata/news',
90 - 'profiles': 'profiles',
91 -}
92 +from . import _SUBMODULE_PATH_MAP
93
94 class SyncBase(object):
95 '''Base Sync class for subclassing'''
96 --
97 2.0.5

Replies