def test_configuration_error(self): argparser = commandline.mk_argparser(suppress=True) @argparser.bind_main_func def error_main(options, out, err): raise errors.ConfigurationError('bork') self.assertMain( -10, '', 'Error in configuration:\n bork\n', argparser, [])
def test_argparse_with_invalid_args(self): argparser = commandline.mk_argparser(suppress=True, add_help=False) @argparser.bind_main_func def main(options, out, err): pass # this is specifically asserting that if given a positional arg (the '1'), # which isn't valid in our argparse setup, it returns exit code -10. self.assertMain(-10, '', '', argparser, ['1'])
def test_method_run(self): argparser = commandline.mk_argparser(suppress=True) argparser.add_argument("--foon") @argparser.bind_main_func def run(options, out, err): out.write("args: %s" % (options.foon,)) return 0 self.assertMain( 0, 'args: dar\n', '', argparser, args=['--foon', 'dar'])
def test_tty_detection(self): argparser = commandline.mk_argparser( config=False, domain=False, color=True, debug=False, quiet=False, verbose=False, version=False) @argparser.bind_main_func def main(options, out, err): for f in (out, err): name = f.__class__.__name__ if name.startswith("native_"): name = name[len("native_"):] f.write(name, autoline=False) for args, out_kind, err_kind in ( ([], 'TerminfoFormatter', 'PlainTextFormatter'), (['--color=n'], 'PlainTextFormatter', 'PlainTextFormatter'), ): master, out = self._get_pty_pair() err, err_getvalue = _stream_and_getvalue() try: commandline.main(argparser, args, out, err) except SystemExit as e: # Important, without this reading the master fd blocks. out.close() self.assertEqual(None, e.args[0]) # There can be an xterm title update after this. # # XXX: Workaround py34 making it harder to read all data from a # pty due to issue #21090 (http://bugs.python.org/issue21090). out_name = '' try: while True: out_name += os.read(master.fileno(), 1).decode() except OSError as e: if e.errno == errno.EIO: pass else: raise master.close() self.assertTrue( out_name.startswith(out_kind) or out_name == 'PlainTextFormatter', 'expected %r, got %r' % (out_kind, out_name)) self.assertEqual(err_kind, err_getvalue()) else: self.fail('no exception raised')
for key, val in config.config.iteritems(): typename = config.type.types.get(key) if typename is None: continue if typename.startswith('ref:'): classes.update(get_classes((val, ))) elif typename.startswith('refs:'): classes.update(get_classes(val)) elif typename.startswith('lazy_refs'): classes.update(get_classes(c.collapse() for c in val)) elif typename.startswith('lazy_ref'): classes.update(get_classes((val.collapse(), ))) return classes shared_options = (commandline.mk_argparser(domain=False, add_help=False), ) argparser = commandline.mk_argparser(suppress=True, parents=shared_options) subparsers = argparser.add_subparsers( description="configuration related subcommands") classes = subparsers.add_parser( "classes", parents=shared_options, description="list all classes referenced by the config") @classes.bind_main_func def classes_main(options, out, err): """List all classes referenced by the config.""" configmanager = options.config sections = [] for name in configmanager.sections():
# Copyright: 2005-2011 Brian Harring <[email protected] # Copyright: 2006 Marien Zwart <*****@*****.**> # License: BSD/GPL2 """repository cache clone utility""" __all__ = ("argparser", "main") import time from pkgcore.util import commandline argparser = commandline.mk_argparser( domain=False, description=__doc__.split('\n', 1)[0]) argparser.add_argument( "source", config_type='cache', action=commandline.StoreConfigObject, priority=20, help="source cache to copy data from") argparser.add_argument( "target", config_type='cache', action=commandline.StoreConfigObject, writable=True, priority=21, help="target cache to update. Must be writable.") @argparser.bind_main_func def main(options, out, err): if options.target.readonly: out.error("can't update cache label '%s', it's marked readonly." % (options.target,))
# Copyright: 2005-2011 Brian Harring <[email protected] # Copyright: 2006 Marien Zwart <*****@*****.**> # License: BSD/GPL2 """pkgcore low-level ebuild utility""" __all__ = ("argparser", "main") from itertools import izip import os from pkgcore.ebuild import atom from pkgcore.ebuild.errors import MalformedAtom from pkgcore.operations import observer from pkgcore.util import commandline argparser = commandline.mk_argparser(description=__doc__.split('\n', 1)[0]) argparser.add_argument("--no-auto", action='store_true', default=False, help="run just the specified phases; " "it's up to the invoker to get the order right") argparser.add_argument( 'pkg', metavar='<atom|ebuild>', help="atom or ebuild matching a pkg to execute phases from") argparser.add_argument('phase', nargs='+', help="phases to run") @argparser.bind_main_func def main(options, out, err): pkg = options.pkg
for key, val in config.config.iteritems(): typename = config.type.types.get(key) if typename is None: continue if typename.startswith('ref:'): classes.update(get_classes((val, ))) elif typename.startswith('refs:'): classes.update(get_classes(val)) elif typename.startswith('lazy_refs'): classes.update(get_classes(c.collapse() for c in val)) elif typename.startswith('lazy_ref'): classes.update(get_classes((val.collapse(), ))) return classes shared_options = (commandline.mk_argparser(domain=False, add_help=False), ) argparser = commandline.mk_argparser(suppress=True, parents=shared_options, description=__doc__.split('\n', 1)[0]) subparsers = argparser.add_subparsers( description="configuration related subcommands") classes = subparsers.add_parser( "classes", parents=shared_options, description="list all classes referenced by the config") @classes.bind_main_func def classes_main(options, out, err): """List all classes referenced by the config.""" configmanager = options.config
for key in vars: val = settings[key] if not val: continue if isinstance(val, tuple): val = ' '.join(val) out.write('%s="%s"' % (key, val)) class arch(_base): """Output the arch defined for this profile""" __metaclass__ = _register_command def __call__(self, namespace, out, err): if namespace.profile.arch is not None: out.write(namespace.profile.arch) _color_parent = commandline.mk_argparser(color=True, domain=False, add_help=False) def bind_parser(parser, name): subparsers = parser.add_subparsers(help="%s commands" % (name,)) for command in commands: subparser = subparsers.add_parser( command.__name__.lower(), help=command.__doc__.split('\n', 1)[0], parents=[_color_parent]) command().bind_to_parser(subparser)
# Copyright: 2011 Brian Harring <*****@*****.**> # Copyright: 2006 Marien Zwart <*****@*****.**> # License: BSD/GPL2 """pkgcore plugin cache update utility""" __all__ = ("argparser", "main") from functools import partial from snakeoil import lists from pkgcore import plugin, plugins from pkgcore.util import commandline argparser = commandline.mk_argparser(config=False, domain=False, color=False, description=__doc__.split('\n', 1)[0]) argparser.add_argument( "packages", nargs="*", action='store', type=partial(commandline.python_namespace_type, module=True), default=[plugins], help="python namespace(s) to regenerate plugins for. If none are " "specified, pkgcore.plugins is updated") @argparser.bind_main_func def main(options, out, err): """Update caches.""" for package in lists.stable_unique(options.packages):
# note the usage of priorities throughout this argparse setup; # priority 0 (commandline sets this): # basically, sort the config first (additions/removals/etc), # priority 30: # sort the repositories # priority 50: # sort the query args individually (potentially accessing the config) along # or lines for each (thus multiple revdep args are or'd together) # priority 90: # finally generate a final query object, a boolean and of all previous # queries. # priority 100: # default priority for DelayedValue; anything else is setup then. argparser = commandline.mk_argparser(domain=True, description="pkgcore query interface") repo_group = argparser.add_argument_group( 'Repository matching options', 'options controlling which repositories to inspect.') repo_group.add_argument( '--raw', action='store_true', default=False, help="With this switch enabled, no configuration is used, and no filtering " " is done. This means you see the raw dependencies, rather than the " "dependencies rendered via your USE configuration. Primarily useful " "for people who need to look under the hood- ebuild devs, PM tool " "authors, etc. Note this option ignores --domain if is specified.") repo_group.add_argument( '--no-filters',
# Copyright: 2005-2011 Brian Harring <[email protected] # Copyright: 2006 Marien Zwart <*****@*****.**> # License: BSD/GPL2 """Clone a repository cache.""" __all__ = ("argparser", "main") import time from pkgcore.util import commandline argparser = commandline.mk_argparser(domain=False, description=__doc__) argparser.add_argument("-v", "--verbose", action='store_true', help="print keys as they are processed") argparser.add_argument("source", config_type='cache', action=commandline.StoreConfigObject, priority=20, help="source cache to copy data from") argparser.add_argument("target", config_type='cache', action=commandline.StoreConfigObject, writable=True, priority=21, help="target cache to update. Must be writable.") @argparser.bind_main_func def main(options, out, err):
# Copyright: 2005-2011 Brian Harring <[email protected] # Copyright: 2006 Marien Zwart <*****@*****.**> # License: BSD/GPL2 """Low-level ebuild operations.""" __all__ = ("argparser", "main") from itertools import izip from pkgcore.util import commandline from pkgcore.ebuild import atom from pkgcore.operations import observer argparser = commandline.mk_argparser(description=__doc__) argparser.add_argument( "--no-auto", action='store_true', default=False, help= "run just the specified phases; it's up to the invoker to get the order right" ) argparser.add_argument('atom', type=atom.atom, help="atom to match a pkg to execute phases from") argparser.add_argument('phase', nargs='+', help="phases to run") @argparser.bind_main_func def main(options, out, err): pkgs = options.domain.all_repos.match(options.atom) if not pkgs:
# Copyright: 2011 Brian Harring <*****@*****.**> # Copyright: 2006 Marien Zwart <*****@*****.**> # License: BSD/GPL2 """Update the plugin cache.""" __all__ = ("argparser", "main") from pkgcore.util import commandline from pkgcore import plugin, plugins from snakeoil import lists, currying argparser = commandline.mk_argparser(config=False, domain=False, color=False, description = __doc__) argparser.add_argument("packages", nargs="*", action='store', type=currying.partial(commandline.python_namespace_type, module=True), default=[plugins], help="python namespace(s) to regenerate plugins for. If none are " "specified, pkgcore.plugins is updated") @argparser.bind_main_func def main(options, out, err): """Update caches.""" if not options.packages: from pkgcore import plugins options.packages = [plugins] for package in lists.stable_unique(options.packages): out.write('Updating cache for %s...' % (package.__name__,)) plugin.initialize_cache(package, force=True)
# Copyright: 2011 Brian Harring <*****@*****.**> # Copyright: 2006 Marien Zwart <*****@*****.**> # License: BSD/GPL2 """Commandline interface to :obj:`pkgcore.ebuild.filter_env`.""" __all__ = ("argparser", "main") import sys from pkgcore.util import commandline # ordering here matters; commandline does a trick to copy to avoid the heavy inspect load. from pkgcore.ebuild import filter_env from pkgcore.log import logger argparser = commandline.mk_argparser(config=False, domain=False, color=False) argparser.add_argument( '-V', '--var-match', action='store_true', default=False, help="Invert the filtering- instead of removing a var if it matches " "remove all vars that do not match") argparser.add_argument( '-F', '--func-match', action='store_true', default=False, help="Invert the filtering- instead of removing a function if it matches " "remove all functions that do not match")
# note the usage of priorities throughout this argparse setup; # priority 0 (commandline sets this): # basically, sort the config first (additions/removals/etc), # priority 30: # sort the repositories # priority 50: # sort the query args individually (potentially accessing the config) along # or lines for each (thus multiple revdep args are or'd together) # priority 90: # finally generate a final query object, a boolean and of all previous # queries. # priority 100: # default priority for DelayedValue; anything else is setup then. argparser = commandline.mk_argparser(domain=True, description="pkgcore query interface") repo_group = argparser.add_argument_group('Repository matching options', 'options controlling which repositories to inspect.') repo_group.add_argument('--raw', action='store_true', default=False, help="With this switch enabled, no configuration is used, and no filtering " " is done. This means you see the raw dependencies, rather than the " "dependencies rendered via your USE configuration. Primarily useful " "for people who need to look under the hood- ebuild devs, PM tool " "authors, etc. Note this option ignores --domain if is specified.") repo_group.add_argument('--no-filters', action='store_true', default=False, help="With this option enabled, all license filtering, visibility filtering" " (ACCEPT_KEYWORDS, package masking, etc) is turned off.") repo_group.add_argument('--virtuals', action='store', choices=('only', 'disable'), help='arg "only" for only matching virtuals, "disable" to not match ' 'virtuals at all. Default is to match everything.')
from time import time from pkgcore.ebuild import resolver from pkgcore.ebuild.atom import atom from pkgcore.merge import errors as merge_errors from pkgcore.operations import observer, format from pkgcore.resolver.util import reduce_to_failures from pkgcore.restrictions import packages, values from pkgcore.restrictions.boolean import AndRestriction, OrRestriction from pkgcore.util import commandline, parserestrict, repo_utils, argparse from snakeoil.compatibility import IGNORED_EXCEPTIONS from snakeoil.currying import partial from snakeoil.lists import stable_unique argparser = commandline.mk_argparser(domain=True, description="pkgcore package merging and unmerging interface") class StoreTarget(argparse._AppendAction): def __call__(self, parser, namespace, values, option_string=None): if isinstance(values, basestring): values = [values] for x in values: if x.startswith('@'): ret = parser._parse_known_args(['--set', x[1:]], namespace) if ret[1]: raise RuntimeError("failed parsing %r, %r, got back %r" % (option_string, values, ret[1])) else: argparse._AppendAction.__call__(self, parser, namespace,
'pkgcore.merge:triggers@merge_triggers', 'pkgcore.sync:base@sync_base', 're', ) def format_seq(seq, formatter=repr): if not seq: seq = None elif len(seq) == 1: seq = seq[0] else: seq = tuple(sorted(str(x) for x in seq)) return formatter(seq) shared_options = (commandline.mk_argparser(domain=False, add_help=False),) argparser = commandline.mk_argparser(suppress=True, parents=shared_options, description="commandline access to various system/repository maintenance functionality") subparsers = argparser.add_subparsers(description="general system maintenance") sync = subparsers.add_parser("sync", parents=shared_options, description="synchronize a local repository with it's defined remote") sync.add_argument('repos', nargs='*', help="repositories to sync", action=commandline.StoreRepoObject, store_name=True, raw=True) @sync.bind_main_func def sync_main(options, out, err): """Update a local repositories to match their remote parent""" succeeded, failed = [], [] seen = set() for name, repo in options.repos: # rewrite the name if it has the usual prefix
for key, val in config.config.iteritems(): typename = config.type.types.get(key) if typename is None: continue if typename.startswith("ref:"): classes.update(get_classes((val,))) elif typename.startswith("refs:"): classes.update(get_classes(val)) elif typename.startswith("lazy_refs"): classes.update(get_classes(c.collapse() for c in val)) elif typename.startswith("lazy_ref"): classes.update(get_classes((val.collapse(),))) return classes shared_options = (commandline.mk_argparser(domain=False, add_help=False),) argparser = commandline.mk_argparser(suppress=True, parents=shared_options) subparsers = argparser.add_subparsers(description="configuration related subcommands") classes = subparsers.add_parser( "classes", parents=shared_options, description="list all classes referenced by the config" ) @classes.bind_main_func def classes_main(options, out, err): """List all classes referenced by the config.""" configmanager = options.config sections = [] for name in configmanager.sections(): try: sections.append(configmanager.collapse_named_section(name))
from pkgcore.ebuild import inspect_profile from pkgcore.ebuild import portageq as _portageq from pkgcore.util import commandline demandload( 'collections:defaultdict', 'itertools:groupby,islice', 'operator:attrgetter,itemgetter', 'snakeoil.lists:iflatten_instance,unstable_unique', 'pkgcore:fetch', 'pkgcore.package:errors', 'pkgcore.restrictions:packages', ) shared = (commandline.mk_argparser(domain=False, add_help=False),) argparser = commandline.mk_argparser( suppress=True, parents=shared, description=__doc__.split('\n', 1)[0]) subparsers = argparser.add_subparsers(description="report applets") pkgsets = subparsers.add_parser("pkgsets", description="pkgset related introspection") mux = pkgsets.add_mutually_exclusive_group() mux.add_argument( "--all", action='store_true', default=False, help="display info on all pkgsets") mux.add_argument( "pkgsets", nargs="*", metavar="pkgset", default=[], action=commandline.StoreConfigObject, config_type='pkgset', store_name=True, help="pkgset to inspect")
# Copyright: 2011 Brian Harring <*****@*****.**> # Copyright: 2006 Marien Zwart <*****@*****.**> # License: BSD/GPL2 """Commandline interface to :obj:`pkgcore.ebuild.filter_env`.""" __all__ = ("argparser", "main") import sys from pkgcore.util import commandline # ordering here matters; commandline does a trick to copy to avoid the heavy inspect load. from pkgcore.ebuild import filter_env from pkgcore.log import logger argparser = commandline.mk_argparser(config=False, domain=False, color=False) argparser.add_argument('-V', '--var-match', action='store_true', default=False, help="Invert the filtering- instead of removing a var if it matches " "remove all vars that do not match") argparser.add_argument('-F', '--func-match', action='store_true', default=False, help="Invert the filtering- instead of removing a function if it matches " "remove all functions that do not match") def stdin_default(namespace, attr): if sys.stdin.isatty(): raise ValueError("Refusing to read from stdin since it's a TTY") setattr(namespace, attr, sys.stdin) argparser.add_argument('--input', '-i', action='store',
val = settings[key] if not val: continue if isinstance(val, tuple): val = ' '.join(val) out.write("%s=%s" % (key, val)) class arch(_base): """Output the arch defined for this profile""" __metaclass__ = _register_command def __call__(self, namespace, out, err): if namespace.profile.arch is not None: out.write(namespace.profile.arch) _color_parent = commandline.mk_argparser(color=True, domain=False, add_help=False) def bind_parser(parser, name): subparsers = parser.add_subparsers(help="%s commands" % (name, )) for command in commands: subparser = subparsers.add_parser(command.__name__.lower(), help=command.__doc__, parents=[_color_parent]) command().bind_to_parser(subparser)
from time import time from pkgcore.util import commandline, parserestrict, repo_utils, argparse from pkgcore.ebuild import resolver from pkgcore.operations import observer, format from pkgcore.ebuild.atom import atom from pkgcore.merge import errors as merge_errors from pkgcore.restrictions import packages, values from pkgcore.restrictions.boolean import AndRestriction, OrRestriction from snakeoil import lists, currying from snakeoil.compatibility import IGNORED_EXCEPTIONS from pkgcore.resolver.util import reduce_to_failures argparser = commandline.mk_argparser(domain=True, description="pkgcore package merging and unmerging interface") class StoreTarget(argparse._AppendAction): def __call__(self, parser, namespace, values, option_string=None): if isinstance(values, basestring): values = [values] for x in values: if x.startswith('@'): ret = parser._parse_known_args(['--set', x[1:]], namespace) if ret[1]: raise RuntimeError("failed parsing %r, %r, got back %r" % (option_string, values, ret[1])) else: argparse._AppendAction.__call__(self, parser, namespace,
import sys try: from pkgcore.util import commandline from pkgcore.util.repo_utils import get_raw_repos, get_virtual_repos except ImportError: print('Cannot import pkgcore!', file=sys.stderr) print('Verify it is properly installed and/or PYTHONPATH is set correctly.', file=sys.stderr) if '--debug' not in sys.argv: print('Add --debug to the commandline for a traceback.', file=sys.stderr) else: raise sys.exit(1) argparser = commandline.mk_argparser(color=False, version=False) argparser.add_argument( '-r', '--repo', action=commandline.StoreRepoObject, help='repo to give info about (default from domain if omitted)') @argparser.bind_final_check def check_args(parser, namespace): # Get repo(s) to operate on. if namespace.repo: repos = (namespace.repo,) else: repos = namespace.domain.repos namespace.repos = get_virtual_repos(get_raw_repos(repos), False)
# Copyright: 2006 Marien Zwart <*****@*****.**> # License: BSD/GPL2 """Low-level ebuild operations.""" __all__ = ("argparser", "main") from itertools import izip from pkgcore.util import commandline from pkgcore.ebuild import atom from pkgcore.operations import observer argparser = commandline.mk_argparser(description=__doc__) argparser.add_argument("--no-auto", action='store_true', default=False, help="run just the specified phases; it's up to the invoker to get the order right") argparser.add_argument('atom', type=atom.atom, help="atom to match a pkg to execute phases from") argparser.add_argument('phase', nargs='+', help="phases to run") @argparser.bind_main_func def main(options, out, err): pkgs = options.domain.all_repos.match(options.atom) if not pkgs: err.write('got no matches for %s\n' % (options.atom,)) return 1 if len(pkgs) > 1: err.write('got multiple matches for %s:' % (options.atom,))
from pkgcore.util import commandline from pkgcore.ebuild import portageq as _portageq from pkgcore.ebuild import inspect_profiles from snakeoil.demandload import demandload demandload(globals(), 'snakeoil.lists:iflatten_instance,unstable_unique', 'collections:defaultdict', 'pkgcore:fetch', 'pkgcore.restrictions:packages', 'itertools:groupby,islice', 'operator:attrgetter,itemgetter', 'pkgcore.package:errors', ) shared = (commandline.mk_argparser(domain=False, add_help=False),) argparser = commandline.mk_argparser(suppress=True, parents=shared) subparsers = argparser.add_subparsers(description="report applets") pkgsets = subparsers.add_parser("pkgsets", description="pkgset related introspection") mux = pkgsets.add_mutually_exclusive_group() mux.add_argument("--all", action='store_true', default=False, help="display info on all pkgsets") mux.add_argument("pkgsets", nargs="*", metavar="pkgset", default=[], action=commandline.StoreConfigObject, config_type='pkgset', store_name=True, help="pkgset to inspect") del mux @pkgsets.bind_main_func def pkgsets_run(opts, out, err): if not opts.pkgsets: if not opts.all:
'pkgcore.sync:base@sync_base', 're', ) def format_seq(seq, formatter=repr): if not seq: seq = None elif len(seq) == 1: seq = seq[0] else: seq = tuple(sorted(str(x) for x in seq)) return formatter(seq) shared_options = (commandline.mk_argparser(domain=False, add_help=False), ) argparser = commandline.mk_argparser( suppress=True, parents=shared_options, description= "commandline access to various system/repository maintenance functionality" ) subparsers = argparser.add_subparsers(description="general system maintenance") sync = subparsers.add_parser( "sync", parents=shared_options, description="synchronize a local repository with it's defined remote") sync.add_argument('repos', nargs='*', help="repositories to sync",
'pkgcore.repository:multiplex', 'pkgcore.sync:base@sync_base', ) def format_seq(seq, formatter=repr): if not seq: seq = None elif len(seq) == 1: seq = seq[0] else: seq = tuple(sorted(str(x) for x in seq)) return formatter(seq) shared_options = (commandline.mk_argparser(domain=False, add_help=False),) argparser = commandline.mk_argparser( suppress=True, parents=shared_options, description=__doc__.split('\n', 1)[0]) subparsers = argparser.add_subparsers(description="general system maintenance") sync = subparsers.add_parser( "sync", parents=shared_options, description="synchronize a local repository with its defined remote") sync.add_argument( 'repos', nargs='*', help="repositories to sync", action=commandline.StoreRepoObject, store_name=True, raw=True) sync.add_argument( "-q", "--quiet", action='store_true', help="suppress non-error messages") sync.add_argument(
# Copyright: 2011 Brian Harring <*****@*****.**> # Copyright: 2006 Marien Zwart <*****@*****.**> # License: BSD/GPL2 """filter a bash environment dump""" __all__ = ("argparser", "main") import sys from pkgcore.ebuild import filter_env from pkgcore.log import logger from pkgcore.util import commandline argparser = commandline.mk_argparser( config=False, domain=False, verbose=False, color=False, description=__doc__.split('\n', 1)[0]) def stdin_default(namespace, attr): if sys.stdin.isatty(): raise ValueError("Refusing to read from stdin since it's a TTY") setattr(namespace, attr, sys.stdin) argparser.add_argument( '-i', '--input', action='store', type=commandline.argparse.FileType(), default=commandline.DelayedValue(stdin_default, 0), help='Filename to read the env from (uses stdin if omitted).') filtering = argparser.add_argument_group("Environment filtering options") filtering.add_argument( '-V', '--var-match', action='store_true', default=False,
for key, val in config.config.iteritems(): typename = config.type.types.get(key) if typename is None: continue if typename.startswith('ref:'): classes.update(get_classes((val,))) elif typename.startswith('refs:'): classes.update(get_classes(val)) elif typename.startswith('lazy_refs'): classes.update(get_classes(c.collapse() for c in val)) elif typename.startswith('lazy_ref'): classes.update(get_classes((val.collapse(),))) return classes shared_options = (commandline.mk_argparser( config=False, color=False, version=False, domain=False, add_help=False),) argparser = commandline.mk_argparser( suppress=True, parents=(commandline.mk_argparser(domain=False, add_help=False),), description=__doc__.split('\n', 1)[0]) subparsers = argparser.add_subparsers(description="configuration related subcommands") classes = subparsers.add_parser( "classes", parents=shared_options, description="list all classes referenced by the config") @classes.bind_main_func def classes_main(options, out, err): """List all classes referenced by the config.""" configmanager = options.config sections = [] for name in configmanager.sections(): try: sections.append(configmanager.collapse_named_section(name))
# Copyright: 2005-2011 Brian Harring <[email protected] # Copyright: 2006 Marien Zwart <*****@*****.**> # License: BSD/GPL2 """Clone a repository cache.""" __all__ = ("argparser", "main") import time from pkgcore.util import commandline argparser = commandline.mk_argparser(domain=False, description=__doc__) argparser.add_argument("-v", "--verbose", action='store_true', help="print keys as they are processed") argparser.add_argument("source", config_type='cache', action=commandline.StoreConfigObject, priority=20, help="source cache to copy data from") argparser.add_argument("target", config_type='cache', action=commandline.StoreConfigObject, writable=True, priority=21, help="target cache to update. Must be writable.") @argparser.bind_main_func def main(options, out, err): if options.target.readonly: out.error("can't update cache label '%s', it's marked readonly." % (options.target,)) return 1