* [gentoo-portage-dev] [PATCH] Add --sync-submodule <glsa|news|profiles> (534070)
@ 2014-12-31 8:07 Zac Medico
2015-01-05 13:52 ` Alexander Berntsen
2015-01-07 4:53 ` Brian Dolbec
0 siblings, 2 replies; 6+ messages in thread
From: Zac Medico @ 2014-12-31 8:07 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Zac Medico
This adds support for a new --sync-submodule option to both emerge and
emaint. When this option is used with the sync action, only the selected
submodules are synced. Each submodule is referenced using an abstract
identifier, which serves to hide the implementation details involving
the precise locations of specific submodules within each repository.
Currently, --sync-submodule has no effect for sync protocols other than
rsync, but the new SyncBase._get_submodule_paths() method will be useful
for implementing support in other SyncBase subclasses.
X-Gentoo-Bug: 534070
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=534070
---
man/emaint.1 | 9 ++++++++-
man/emerge.1 | 7 +++++++
pym/_emerge/main.py | 7 +++++++
pym/portage/emaint/main.py | 12 +++++++++++-
pym/portage/emaint/modules/sync/__init__.py | 10 ++++++++++
pym/portage/emaint/modules/sync/sync.py | 19 +++++++++++++++----
pym/portage/module.py | 15 +++++++++++++++
pym/portage/sync/modules/rsync/rsync.py | 16 +++++++++++++++-
pym/portage/sync/syncbase.py | 14 +++++++++++++-
9 files changed, 101 insertions(+), 8 deletions(-)
diff --git a/man/emaint.1 b/man/emaint.1
index f02bc68..67e05f1 100644
--- a/man/emaint.1
+++ b/man/emaint.1
@@ -1,4 +1,4 @@
-.TH "EMAINT" "1" "Nov 2008" "Portage VERSION" "Portage"
+.TH "EMAINT" "1" "Dec 2014" "Portage VERSION" "Portage"
.SH NAME
emaint \- performs system health checks and maintenance
.SH SYNOPSIS
@@ -71,6 +71,13 @@ Sync all repositories which have a sync\-uri specified. (sync command only)
.TP
.B \-r, \-\-repo REPO
Sync the repository specified. (sync command only)
+.TP
+.BR "\-\-sync-submodule <glsa|news|profiles>"
+Restrict sync to the specified submodule(s). This option may be
+specified multiple times, in order to sync multiple submodules.
+Currently, this option has no effect for sync protocols other
+than rsync.
+(sync command only)
.SH "REPORTING BUGS"
Please report bugs via http://bugs.gentoo.org/
.SH AUTHORS
diff --git a/man/emerge.1 b/man/emerge.1
index faa1f33..3d4042c 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -836,6 +836,13 @@ remaining packages and any that have unsatisfied dependencies or are
masked will be automatically dropped. Also see the related
\fB\-\-keep\-going\fR option.
.TP
+.BR "\-\-sync\-submodule <glsa|news|profiles>"
+Restrict sync to the specified submodule(s). This option may be
+specified multiple times, in order to sync multiple submodules.
+Currently, this option has no effect for sync protocols other
+than rsync.
+(--sync action only)
+.TP
.BR "\-\-tree " (\fB\-t\fR)
Shows the dependency tree for the given target by indenting dependencies.
This is only really useful in combination with \fB\-\-emptytree\fR or
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 7c707f9..695a732 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -633,6 +633,13 @@ def parse_opts(tmpcmdline, silent=False):
"choices" : true_y_or_n
},
+ "--sync-submodule": {
+ "help" : ("Restrict sync to the specified submodule(s)."
+ " (--sync action only)"),
+ "choices" : ("glsa", "news", "profiles"),
+ "action" : "append",
+ },
+
"--use-ebuild-visibility": {
"help" : "use unbuilt ebuild metadata for visibility checks on built packages",
"choices" : true_y_or_n
diff --git a/pym/portage/emaint/main.py b/pym/portage/emaint/main.py
index fea4832..25a7706 100644
--- a/pym/portage/emaint/main.py
+++ b/pym/portage/emaint/main.py
@@ -34,6 +34,7 @@ class OptionItem(object):
self.action = opt.get('action')
self.type = opt.get('type')
self.dest = opt.get('dest')
+ self.choices = opt.get('choices')
@property
def pargs(self):
@@ -58,6 +59,8 @@ class OptionItem(object):
kwargs['type'] = self.type
if self.dest is not None:
kwargs['dest'] = self.dest
+ if self.choices is not None:
+ kwargs['choices'] = self.choices
return kwargs
def usage(module_controller):
@@ -89,7 +92,10 @@ def module_opts(module_controller, module):
opts = DEFAULT_OPTIONS
for opt in sorted(opts):
optd = opts[opt]
- opto = " %s, %s" % (optd['short'], optd['long'])
+ if 'short' in optd:
+ opto = " %s, %s" % (optd['short'], optd['long'])
+ else:
+ opto = " %s" % (optd['long'],)
_usage += '%s %s\n' % (opto.ljust(15), optd['help'])
_usage += '\n'
return _usage
@@ -174,6 +180,10 @@ def emaint_main(myargv):
if desc:
for opt in desc:
parser_options.append(OptionItem(desc[opt]))
+ desc = module_controller.get_opt_descriptions(mod)
+ if desc:
+ for opt in desc:
+ parser_options.append(OptionItem(desc[opt]))
for opt in parser_options:
parser.add_argument(*opt.pargs, **opt.kwargs)
diff --git a/pym/portage/emaint/modules/sync/__init__.py b/pym/portage/emaint/modules/sync/__init__.py
index 32469b5..bc6dc5f 100644
--- a/pym/portage/emaint/modules/sync/__init__.py
+++ b/pym/portage/emaint/modules/sync/__init__.py
@@ -37,6 +37,16 @@ module_spec = {
'dest': 'auto',
'func': 'auto_sync',
},
+ },
+ 'opt_desc': {
+ 'sync-submodule': {
+ "long": "--sync-submodule",
+ "help": ("(sync module only): Restrict sync "
+ "to the specified submodule(s)"),
+ "choices": ("glsa", "news", "profiles"),
+ "action": "append",
+ "dest": "sync_submodule",
+ },
}
}
}
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 77c685c..c6aef95 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -90,7 +90,8 @@ class SyncRepos(object):
return_messages = options.get('return-messages', False)
else:
return_messages = False
- return self._sync(selected, return_messages)
+ return self._sync(selected, return_messages,
+ emaint_opts=options)
def all_repos(self, **kwargs):
@@ -101,7 +102,8 @@ class SyncRepos(object):
return_messages = options.get('return-messages', False)
else:
return_messages = False
- return self._sync(selected, return_messages)
+ return self._sync(selected, return_messages,
+ emaint_opts=options)
def repo(self, **kwargs):
@@ -123,7 +125,8 @@ class SyncRepos(object):
if return_messages:
return msgs
return
- return self._sync(selected, return_messages)
+ return self._sync(selected, return_messages,
+ emaint_opts=options)
@staticmethod
@@ -189,7 +192,15 @@ class SyncRepos(object):
return selected
- def _sync(self, selected_repos, return_messages):
+ def _sync(self, selected_repos, return_messages,
+ emaint_opts=None):
+
+ if emaint_opts is not None:
+ for k, v in emaint_opts.items():
+ if v is not None:
+ k = "--" + k.replace("_", "-")
+ self.emerge_config.opts[k] = v
+
msgs = []
if not selected_repos:
msgs.append("Emaint sync, nothing to sync... returning")
diff --git a/pym/portage/module.py b/pym/portage/module.py
index a78bb2e..e40a548 100644
--- a/pym/portage/module.py
+++ b/pym/portage/module.py
@@ -179,3 +179,18 @@ class Modules(object):
raise InvalidModuleName("Module name '%s' was invalid or not"
%modname + "found")
return desc
+
+ def get_opt_descriptions(self, modname):
+ """Retrieves the module class exported options descriptions
+
+ @type modname: string
+ @param modname: the module class name
+ @type dictionary
+ @return: the modules class exported options descriptions
+ """
+ if modname and modname in self.module_names:
+ desc = self._modules[modname].get('opt_desc')
+ else:
+ raise InvalidModuleName(
+ "Module name '%s' was invalid or not found" % modname)
+ return desc
diff --git a/pym/portage/sync/modules/rsync/rsync.py b/pym/portage/sync/modules/rsync/rsync.py
index 74c10e7..900351d 100644
--- a/pym/portage/sync/modules/rsync/rsync.py
+++ b/pym/portage/sync/modules/rsync/rsync.py
@@ -488,7 +488,21 @@ class RsyncSync(SyncBase):
exitcode = SERVER_OUT_OF_DATE
elif (servertimestamp == 0) or (servertimestamp > timestamp):
# actual sync
- command = rsynccommand + [syncuri+"/", self.repo.location]
+ command = rsynccommand[:]
+ submodule_paths = self._get_submodule_paths()
+ if submodule_paths:
+ # The only way to select multiple directories to
+ # sync, without calling rsync multiple times, is
+ # to use --relative.
+ command.append("--relative")
+ for path in submodule_paths:
+ # /./ is special syntax supported with the
+ # rsync --relative option.
+ command.append(syncuri + "/./" + path)
+ command.append(self.repo.location)
+ else:
+ command.extend([syncuri + "/", self.repo.location])
+
exitcode = None
try:
exitcode = portage.process.spawn(command,
diff --git a/pym/portage/sync/syncbase.py b/pym/portage/sync/syncbase.py
index 94d4aab..fcde51f 100644
--- a/pym/portage/sync/syncbase.py
+++ b/pym/portage/sync/syncbase.py
@@ -12,6 +12,11 @@ import os
import portage
from portage.util import writemsg_level
+_SUBMODULE_PATH_MAP = {
+ 'glsa': 'metadata/glsa',
+ 'news': 'metadata/news',
+ 'profiles': 'profiles',
+}
class SyncBase(object):
'''Base Sync class for subclassing'''
@@ -57,7 +62,6 @@ class SyncBase(object):
self.xterm_titles = self.options.get('xterm_titles', False)
self.spawn_kwargs = self.options.get('spawn_kwargs', None)
-
def exists(self, **kwargs):
'''Tests whether the repo actually exists'''
if kwargs:
@@ -100,3 +104,11 @@ class SyncBase(object):
# and portdb properly account for its existence.
'''
pass
+
+ def _get_submodule_paths(self):
+ paths = []
+ emerge_config = self.options.get('emerge_config')
+ if emerge_config is not None:
+ for name in emerge_config.opts.get('--sync-submodule', []):
+ paths.append(_SUBMODULE_PATH_MAP[name])
+ return tuple(paths)
--
2.0.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] Add --sync-submodule <glsa|news|profiles> (534070)
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
1 sibling, 0 replies; 6+ messages in thread
From: Alexander Berntsen @ 2015-01-05 13:52 UTC (permalink / raw
To: gentoo-portage-dev
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
LGTM, go ahead & merge.
- --
Alexander
bernalex@gentoo.org
https://secure.plaimi.net/~alexander
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iF4EAREIAAYFAlSqlzgACgkQRtClrXBQc7X7EQD/YvLH6UXnO6x+LZsyr/A4SZPm
d8pLIE30uYv6hA5SidIA/34TUCXrg0dxNFjJ7VeYPUC8/KxCy2Jjv2nQqVJCyluc
=oXF9
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] Add --sync-submodule <glsa|news|profiles> (534070)
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
1 sibling, 1 reply; 6+ messages in thread
From: Brian Dolbec @ 2015-01-07 4:53 UTC (permalink / raw
To: gentoo-portage-dev
On Wed, 31 Dec 2014 00:07:19 -0800
Zac Medico <zmedico@gentoo.org> wrote:
> This adds support for a new --sync-submodule option to both emerge and
> emaint. When this option is used with the sync action, only the
> selected submodules are synced. Each submodule is referenced using an
> abstract identifier, which serves to hide the implementation details
> involving the precise locations of specific submodules within each
> repository.
>
> Currently, --sync-submodule has no effect for sync protocols other
> than rsync, but the new SyncBase._get_submodule_paths() method will
> be useful for implementing support in other SyncBase subclasses.
>
> X-Gentoo-Bug: 534070
> X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=534070
> ---
>
> portage.process.spawn(command, diff --git
> a/pym/portage/sync/syncbase.py b/pym/portage/sync/syncbase.py index
> 94d4aab..fcde51f 100644 --- a/pym/portage/sync/syncbase.py
> +++ b/pym/portage/sync/syncbase.py
> @@ -12,6 +12,11 @@ import os
> import portage
> from portage.util import writemsg_level
>
> +_SUBMODULE_PATH_MAP = {
> + 'glsa': 'metadata/glsa',
> + 'news': 'metadata/news',
> + 'profiles': 'profiles',
> +}
>
>
It mostly looks good, but...
I don't like the idea of hard-coding this in the base class.
I think this should be configurable per-repo or at least per repo type.
This patch clears the way for other repo types to have sub-modules, but
will they be the same mapping for a git tree with those as
sub-modules? Maybe I'm just not following how the system works
properly...
Alternatively...if the above is wrong/not feasible. In the
sync/__init__.py you have the choices hard-coded there independently of
these definitions above. I would prefer that one get it's options from
the other. Since syncbase.py is not gauranteed to be loaded, I would
think that the above be declared in the sync module's __init__.py and
imported or passed in here. Then the:
"choices": ("glsa", "news", "profiles"),
could become:
"choices": list(_SUBMODULE_PATH_MAP)
Then there is only one place to edit as options or code change.
--
Brian Dolbec <dolsen>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] Add --sync-submodule <glsa|news|profiles> (534070)
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
0 siblings, 1 reply; 6+ messages in thread
From: Zac Medico @ 2015-01-07 9:31 UTC (permalink / raw
To: gentoo-portage-dev
On 01/06/2015 08:53 PM, Brian Dolbec wrote:
> On Wed, 31 Dec 2014 00:07:19 -0800
> Zac Medico <zmedico@gentoo.org> wrote:
>
>> This adds support for a new --sync-submodule option to both emerge and
>> emaint. When this option is used with the sync action, only the
>> selected submodules are synced. Each submodule is referenced using an
>> abstract identifier, which serves to hide the implementation details
>> involving the precise locations of specific submodules within each
>> repository.
>>
>> Currently, --sync-submodule has no effect for sync protocols other
>> than rsync, but the new SyncBase._get_submodule_paths() method will
>> be useful for implementing support in other SyncBase subclasses.
>>
>> X-Gentoo-Bug: 534070
>> X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=534070
>> ---
>>
>> portage.process.spawn(command, diff --git
>> a/pym/portage/sync/syncbase.py b/pym/portage/sync/syncbase.py index
>> 94d4aab..fcde51f 100644 --- a/pym/portage/sync/syncbase.py
>> +++ b/pym/portage/sync/syncbase.py
>> @@ -12,6 +12,11 @@ import os
>> import portage
>> from portage.util import writemsg_level
>>
>> +_SUBMODULE_PATH_MAP = {
>> + 'glsa': 'metadata/glsa',
>> + 'news': 'metadata/news',
>> + 'profiles': 'profiles',
>> +}
>>
>>
>
> It mostly looks good, but...
>
> I don't like the idea of hard-coding this in the base class.
>
> I think this should be configurable per-repo or at least per repo type.
The paths should be the same as long as the repo conforms to existing
conventions. If the repo doesn't conform to existing conventions, then
existing tools won't know where to look for the glsa, news, and profiles
directories.
> This patch clears the way for other repo types to have sub-modules, but
> will they be the same mapping for a git tree with those as
> sub-modules? Maybe I'm just not following how the system works
> properly...
Yes, they should use the same mappings, as explained above.
> Alternatively...if the above is wrong/not feasible. In the
> sync/__init__.py you have the choices hard-coded there independently of
> these definitions above. I would prefer that one get it's options from
> the other. Since syncbase.py is not gauranteed to be loaded, I would
> think that the above be declared in the sync module's __init__.py and
> imported or passed in here. Then the:
>
> "choices": ("glsa", "news", "profiles"),
>
> could become:
>
> "choices": list(_SUBMODULE_PATH_MAP)
>
> Then there is only one place to edit as options or code change.
That's a good idea. I'll make a patch for that.
--
Thanks,
Zac
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gentoo-portage-dev] [PATCH] Use _SUBMODULE_PATH_MAP keys for option choices
2015-01-07 9:31 ` Zac Medico
@ 2015-01-07 10:08 ` Zac Medico
2015-01-08 4:31 ` Brian Dolbec
0 siblings, 1 reply; 6+ messages in thread
From: Zac Medico @ 2015-01-07 10:08 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Zac Medico
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'''
--
2.0.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] Use _SUBMODULE_PATH_MAP keys for option choices
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
0 siblings, 0 replies; 6+ messages in thread
From: Brian Dolbec @ 2015-01-08 4:31 UTC (permalink / raw
To: gentoo-portage-dev
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>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-01-08 4:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox