Пример #1
0
def parse_args(args):
    description = "emirrordist - a fetch tool for mirroring " \
     "of package distfiles"
    usage = "emirrordist [options] <action>"
    parser = ArgumentParser(description=description, usage=usage)

    actions = parser.add_argument_group('Actions')
    actions.add_argument("--version",
                         action="store_true",
                         help="display portage version and exit")
    actions.add_argument("--mirror",
                         action="store_true",
                         help="mirror distfiles for the selected repository")

    common = parser.add_argument_group('Common options')
    for opt_info in common_options:
        opt_pargs = [opt_info["longopt"]]
        if opt_info.get("shortopt"):
            opt_pargs.append(opt_info["shortopt"])
        opt_kwargs = {"help": opt_info["help"]}
        for k in ("action", "choices", "default", "metavar", "type"):
            if k in opt_info:
                opt_kwargs[k] = opt_info[k]
        common.add_argument(*opt_pargs, **opt_kwargs)

    options, args = parser.parse_known_args(args)

    return (parser, options, args)
Пример #2
0
def parse_args(args):
	description = "emirrordist - a fetch tool for mirroring " \
		"of package distfiles"
	usage = "emirrordist [options] <action>"
	parser = ArgumentParser(description=description, usage=usage)

	actions = parser.add_argument_group('Actions')
	actions.add_argument("--version",
		action="store_true",
		help="display portage version and exit")
	actions.add_argument("--mirror",
		action="store_true",
		help="mirror distfiles for the selected repository")

	common = parser.add_argument_group('Common options')
	for opt_info in common_options:
		opt_pargs = [opt_info["longopt"]]
		if opt_info.get("shortopt"):
			opt_pargs.append(opt_info["shortopt"])
		opt_kwargs = {"help" : opt_info["help"]}
		for k in ("action", "choices", "default", "metavar", "type"):
			if k in opt_info:
				opt_kwargs[k] = opt_info[k]
		common.add_argument(*opt_pargs, **opt_kwargs)

	options, args = parser.parse_known_args(args)

	return (parser, options, args)
Пример #3
0
def main(argv):

    parser = ArgumentParser(description=doc)
    parser.add_argument('paths', nargs='*', default=[])

    actions = parser.add_argument_group('Actions')
    actions.add_argument('--dump',
                         action='store_true',
                         help='Dump the values of all extended '
                         'attributes associated with null-separated'
                         ' paths read from stdin.')
    actions.add_argument('--restore',
                         action='store_true',
                         help='Restore extended attributes using'
                         ' a dump read from stdin.')

    options = parser.parse_args(argv)

    if sys.hexversion >= 0x3000000:
        file_in = sys.stdin.buffer.raw
    else:
        file_in = sys.stdin
    if not options.paths:
        options.paths += [x for x in file_in.read().split(b'\0') if x]

    if options.dump:
        if sys.hexversion >= 0x3000000:
            file_out = sys.stdout.buffer
        else:
            file_out = sys.stdout
        dump_xattrs(options.paths, file_out)

    elif options.restore:
        restore_xattrs(file_in)

    else:
        parser.error('missing action!')

    return os.EX_OK
Пример #4
0
def main(argv):

	parser = ArgumentParser(description=__doc__)
	parser.add_argument('paths', nargs='*', default=[])

	actions = parser.add_argument_group('Actions')
	actions.add_argument('--dump',
		action='store_true',
		help='Dump the values of all extended '
			'attributes associated with null-separated'
			' paths read from stdin.')
	actions.add_argument('--restore',
		action='store_true',
		help='Restore extended attributes using'
			' a dump read from stdin.')

	options = parser.parse_args(argv)

	if sys.hexversion >= 0x3000000:
		file_in = sys.stdin.buffer.raw
	else:
		file_in = sys.stdin
	if not options.paths:
		options.paths += [x for x in file_in.read().split(b'\0') if x]

	if options.dump:
		if sys.hexversion >= 0x3000000:
			file_out = sys.stdout.buffer
		else:
			file_out = sys.stdout
		dump_xattrs(options.paths, file_out)

	elif options.restore:
		restore_xattrs(file_in)

	else:
		parser.error('missing action!')

	return os.EX_OK