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