# Distributed under the terms of the GNU General Public License v2
import logging
-import optparse
import sys
import portage
from portage import os
from portage.util import normalize_path, writemsg_level
+from portage.util._argparse import ArgumentParser
from portage.util._async.run_main_scheduler import run_main_scheduler
from portage.util._async.SchedulerInterface import SchedulerInterface
from portage.util._eventloop.global_event_loop import global_event_loop
{
"longopt" : "--jobs",
"shortopt" : "-j",
- "help" : "number of concurrent jobs to run"
+ "help" : "number of concurrent jobs to run",
+ "type" : int
},
{
"longopt" : "--load-average",
"shortopt" : "-l",
"help" : "load average limit for spawning of new concurrent jobs",
- "metavar" : "LOAD"
+ "metavar" : "LOAD",
+ "type" : float
},
{
"longopt" : "--tries",
"help" : "maximum number of tries per file, 0 means unlimited (default is 10)",
- "default" : 10
+ "default" : 10,
+ "type" : int
},
{
"longopt" : "--repo",
"help" : "manually override \"strict\" FEATURES setting",
"choices" : ("y", "n"),
"metavar" : "<y|n>",
- "type" : "choice"
},
{
"longopt" : "--failure-log",
"recycle dir, measured in seconds (defaults to "
"the equivalent of 60 days)",
"default" : 60 * seconds_per_day,
- "metavar" : "SECONDS"
+ "metavar" : "SECONDS",
+ "type" : int
},
{
"longopt" : "--fetch-log-dir",
description = "emirrordist - a fetch tool for mirroring " \
"of package distfiles"
usage = "emirrordist [options] <action>"
- parser = optparse.OptionParser(description=description, usage=usage)
+ parser = ArgumentParser(description=description, usage=usage)
- actions = optparse.OptionGroup(parser, 'Actions')
- actions.add_option("--version",
+ actions = parser.add_argument_group('Actions')
+ actions.add_argument("--version",
action="store_true",
help="display portage version and exit")
- actions.add_option("--mirror",
+ actions.add_argument("--mirror",
action="store_true",
help="mirror distfiles for the selected repository")
- parser.add_option_group(actions)
- common = optparse.OptionGroup(parser, 'Common options')
+ common = parser.add_argument_group('Common options')
for opt_info in common_options:
opt_pargs = [opt_info["longopt"]]
if opt_info.get("shortopt"):
for k in ("action", "choices", "default", "metavar", "type"):
if k in opt_info:
opt_kwargs[k] = opt_info[k]
- common.add_option(*opt_pargs, **opt_kwargs)
- parser.add_option_group(common)
+ common.add_argument(*opt_pargs, **opt_kwargs)
- options, args = parser.parse_args(args)
+ options, args = parser.parse_known_args(args)
return (parser, options, args)