本文整理汇总了Python中argparse.REMAINDER属性的典型用法代码示例。如果您正苦于以下问题:Python argparse.REMAINDER属性的具体用法?Python argparse.REMAINDER怎么用?Python argparse.REMAINDER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类argparse
的用法示例。
在下文中一共展示了argparse.REMAINDER属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: symlink
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import REMAINDER [as 别名]
def symlink(parser, cmd, args):
"""
Set up symlinks for (a subset of) the pwny apps.
"""
parser.add_argument(
'apps',
nargs=argparse.REMAINDER,
help='Which apps to create symlinks for.'
)
args = parser.parse_args(args)
base_dir, pwny_main = os.path.split(sys.argv[0])
for app_name, config in MAIN_FUNCTIONS.items():
if not config['symlink'] or (args.apps and app_name not in args.apps):
continue
dest = os.path.join(base_dir, app_name)
if not os.path.exists(dest):
print('Creating symlink %s' % dest)
os.symlink(pwny_main, dest)
else:
print('Not creating symlink %s (file already exists)' % dest)
示例2: ideinit
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import REMAINDER [as 别名]
def ideinit(args, refreshOnly=False, buildProcessorJars=True):
"""(re)generate IDE project configurations"""
parser = ArgumentParser(prog='mx ideinit')
parser.add_argument('--no-python-projects', action='store_false', dest='pythonProjects', help='Do not generate projects for the mx python projects.')
parser.add_argument('remainder', nargs=REMAINDER, metavar='...')
args = parser.parse_args(args)
mx_ide = os.environ.get('MX_IDE', 'all').lower()
all_ides = mx_ide == 'all'
if all_ides or mx_ide == 'eclipse':
mx_ide_eclipse.eclipseinit(args.remainder, refreshOnly=refreshOnly, buildProcessorJars=buildProcessorJars, doFsckProjects=False, pythonProjects=args.pythonProjects)
if all_ides or mx_ide == 'netbeans':
mx_ide_netbeans.netbeansinit(args.remainder, refreshOnly=refreshOnly, buildProcessorJars=buildProcessorJars, doFsckProjects=False)
if all_ides or mx_ide == 'intellij':
mx_ide_intellij.intellijinit(args.remainder, refreshOnly=refreshOnly, doFsckProjects=False, mx_python_modules=args.pythonProjects)
if not refreshOnly:
fsckprojects([])
示例3: doArchive
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import REMAINDER [as 别名]
def doArchive(argv, bobRoot):
subHelp = "\n ... ".join(sorted(
[ "{:8} {}".format(c, d[1]) for (c, d) in availableArchiveCmds.items() ]))
parser = argparse.ArgumentParser(prog="bob archive",
formatter_class=argparse.RawDescriptionHelpFormatter,
description="""Manage binary artifacts archive. The following subcommands are available:
bob archive {}
""".format(subHelp))
parser.add_argument('subcommand', help="Subcommand")
parser.add_argument('args', nargs=argparse.REMAINDER,
help="Arguments for subcommand")
args = parser.parse_args(argv)
if args.subcommand in availableArchiveCmds:
availableArchiveCmds[args.subcommand][0](args.args)
else:
parser.error("Unknown subcommand '{}'".format(args.subcommand))
示例4: add_arguments
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import REMAINDER [as 别名]
def add_arguments(self, parser, cli_name):
arg = parser.add_argument(
'--prefix',
help='Prefix command, which should go before the executable. '
'Command must be wrapped in quotes if it contains spaces '
"(e.g. --prefix 'gdb -ex run --args').")
try:
from argcomplete.completers import SuppressCompleter
except ImportError:
pass
else:
arg.completer = SuppressCompleter()
arg = parser.add_argument(
'package_name',
help='Name of the ROS package')
arg.completer = package_name_completer
arg = parser.add_argument(
'executable_name',
help='Name of the executable')
arg.completer = ExecutableNameCompleter(
package_name_key='package_name')
parser.add_argument(
'argv', nargs=REMAINDER,
help='Pass arbitrary arguments to the executable')
示例5: cinch_generic
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import REMAINDER [as 别名]
def cinch_generic(playbook, help_description):
# Parse the command line arguments
parser = ArgumentParser(description='A CLI wrapper for ansible-playbook '
'to run cinch playbooks. ' + help_description)
# The inventory file that the user provides which will get passed along to
# Ansible for its consumption
parser.add_argument('inventory', help='Ansible inventory file (required)')
# All remaining arguments are passed through, untouched, to Ansible
parser.add_argument('args', nargs=REMAINDER, help='extra args to '
'pass to the ansible-playbook command (optional)')
args = parser.parse_args()
if len(args.inventory) > 0:
if args.inventory[0] == '/':
inventory = args.inventory
else:
inventory = path.join(getcwd(), args.inventory)
else:
raise Exception('Inventory path needs to be non-empty')
exit_code = call_ansible(inventory, playbook, args.args)
sys.exit(exit_code)
示例6: set_options
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import REMAINDER [as 别名]
def set_options(self):
super(Module, self).set_options()
self.options.add_argument("--binary", help="Path to binary")
self.options.add_argument(
"-o",
"--output_path",
help="Path which will contain program output (relative to base_path in config",
default=self.name,
)
self.options.add_argument(
"--tool_args",
help="Additional arguments to be passed to the tool",
nargs=argparse.REMAINDER,
)
self.options.add_argument("-d", "--domain", help="Domain to search.")
self.options.add_argument('-s', '--scope', help="How to scope results (Default passive)", choices=["active", "passive", "none"], default="passive")
self.options.add_argument(
"--no_binary",
help="Runs through without actually running the binary. Useful for if you already ran the tool and just want to process the output.",
action="store_true",
)
示例7: load_config
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import REMAINDER [as 别名]
def load_config():
parser = argparse.ArgumentParser()
parser.add_argument('--config', type=str)
parser.add_argument('--resume', type=str, default='')
parser.add_argument('--local_rank', type=int, default=0)
parser.add_argument('options', default=None, nargs=argparse.REMAINDER)
args = parser.parse_args()
config = get_default_config()
if args.config is not None:
config.merge_from_file(args.config)
config.merge_from_list(args.options)
if not torch.cuda.is_available():
config.device = 'cpu'
config.train.dataloader.pin_memory = False
if args.resume != '':
config_path = pathlib.Path(args.resume) / 'config.yaml'
config.merge_from_file(config_path.as_posix())
config.merge_from_list(['train.resume', True])
config.merge_from_list(['train.dist.local_rank', args.local_rank])
config = update_config(config)
config.freeze()
return config
示例8: parse_args
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import REMAINDER [as 别名]
def parse_args():
"""
Parse input arguments
"""
parser = argparse.ArgumentParser(description='Test a Fast R-CNN network')
parser.add_argument('--cfg', dest='cfg_file',
help='optional config file', default=None, type=str)
parser.add_argument('--model', dest='model',
help='model to test',
default=None, type=str)
parser.add_argument('--imdb', dest='imdb_name',
help='dataset to test',
default='voc_2007_test', type=str)
parser.add_argument('--comp', dest='comp_mode', help='competition mode',
action='store_true')
parser.add_argument('--num_dets', dest='max_per_image',
help='max number of detections per image',
default=100, type=int)
parser.add_argument('--tag', dest='tag',
help='tag of the model',
default='', type=str)
parser.add_argument('--net', dest='net',
help='vgg16, res50, res101, res152, mobile',
default='res50', type=str)
parser.add_argument('--set', dest='set_cfgs',
help='set config keys', default=None,
nargs=argparse.REMAINDER)
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
return args
开发者ID:Sunarker,项目名称:Collaborative-Learning-for-Weakly-Supervised-Object-Detection,代码行数:36,代码来源:test_net.py
示例9: parse_args
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import REMAINDER [as 别名]
def parse_args():
"""
Parse input arguments
"""
parser = argparse.ArgumentParser(description='Train a faster-rcnn in wealy supervised situation with wsddn modules')
parser.add_argument('--cfg', dest='cfg_file',
help='optional config file',
default=None, type=str)
parser.add_argument('--weight', dest='weight',
help='initialize with pretrained model weights',
type=str)
parser.add_argument('--wsddn', dest='wsddn',
help='initialize with pretrained wsddn model weights',
type=str)
parser.add_argument('--imdb', dest='imdb_name',
help='dataset to train on',
default='voc_2007_trainval', type=str)
parser.add_argument('--imdbval', dest='imdbval_name',
help='dataset to validate on',
default='voc_2007_test', type=str)
parser.add_argument('--iters', dest='max_iters',
help='number of iterations to train',
default=70000, type=int)
parser.add_argument('--tag', dest='tag',
help='tag of the model',
default=None, type=str)
parser.add_argument('--net', dest='net',
help='vgg16, res50, res101, res152, mobile',
default='res50', type=str)
parser.add_argument('--set', dest='set_cfgs',
help='set config keys', default=None,
nargs=argparse.REMAINDER)
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
return args
开发者ID:Sunarker,项目名称:Collaborative-Learning-for-Weakly-Supervised-Object-Detection,代码行数:41,代码来源:trainval_net.py
示例10: intellijinit_cli
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import REMAINDER [as 别名]
def intellijinit_cli(args):
"""(re)generate Intellij project configurations"""
parser = ArgumentParser(prog='mx ideinit')
parser.add_argument('--no-python-projects', action='store_false', dest='pythonProjects', help='Do not generate projects for the mx python projects.')
parser.add_argument('--no-external-projects', action='store_false', dest='externalProjects', help='Do not generate external projects.')
parser.add_argument('--no-java-projects', '--mx-python-modules-only', action='store_false', dest='javaModules', help='Do not generate projects for the java projects.')
parser.add_argument('--native-projects', action='store_true', dest='nativeProjects', help='Generate native projects.')
parser.add_argument('remainder', nargs=REMAINDER, metavar='...')
args = parser.parse_args(args)
intellijinit(args.remainder, mx_python_modules=args.pythonProjects, java_modules=args.javaModules,
generate_external_projects=args.externalProjects, native_projects=args.nativeProjects)
示例11: parse_args
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import REMAINDER [as 别名]
def parse_args():
parser = argparse.ArgumentParser(description='Train keypoints network')
# general
parser.add_argument('--cfg',
help='experiment configure file name',
required=True,
type=str)
parser.add_argument('opts',
help="Modify config options using the command-line",
default=None,
nargs=argparse.REMAINDER)
# philly
parser.add_argument('--modelDir',
help='model directory',
type=str,
default='')
parser.add_argument('--logDir',
help='log directory',
type=str,
default='')
parser.add_argument('--dataDir',
help='data directory',
type=str,
default='')
parser.add_argument('--prevModelDir',
help='prev Model directory',
type=str,
default='')
args = parser.parse_args()
return args
示例12: parse_args
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import REMAINDER [as 别名]
def parse_args():
parser = argparse.ArgumentParser(description='Train keypoints network')
# general
parser.add_argument('--cfg',
help='experiment configure file name',
required=True,
type=str)
parser.add_argument('opts',
help="Modify config options using the command-line",
default=None,
nargs=argparse.REMAINDER)
# philly
parser.add_argument('--modelDir',
help='model directory',
type=str,
default='')
parser.add_argument('--logDir',
help='log directory',
type=str,
default='')
parser.add_argument('--dataDir',
help='data directory',
type=str,
default='')
parser.add_argument('--prevModelDir',
help='prev Model directory',
type=str,
default='')
args = parser.parse_args()
return args
示例13: parse_args
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import REMAINDER [as 别名]
def parse_args():
"""
Helper function parsing the command line options
@retval ArgumentParser
"""
parser = ArgumentParser(description="PyTorch distributed training launch "
"helper utilty that will spawn up "
"multiple distributed processes")
# Optional arguments for the launch helper
parser.add_argument("--nnodes", type=int, default=1,
help="The number of nodes to use for distributed "
"training")
parser.add_argument("--node_rank", type=int, default=0,
help="The rank of the node for multi-node distributed "
"training")
parser.add_argument("--nproc_per_node", type=int, default=1,
help="The number of processes to launch on each node, "
"for GPU training, this is recommended to be set "
"to the number of GPUs in your system so that "
"each process can be bound to a single GPU.")
parser.add_argument("--master_addr", default="127.0.0.1", type=str,
help="Master node (rank 0)'s address, should be either "
"the IP address or the hostname of node 0, for "
"single node multi-proc training, the "
"--master_addr can simply be 127.0.0.1")
parser.add_argument("--master_port", default=29500, type=int,
help="Master node (rank 0)'s free port that needs to "
"be used for communciation during distributed "
"training")
# positional
parser.add_argument("training_script", type=str,
help="The full path to the single GPU training "
"program/script to be launched in parallel, "
"followed by all the arguments for the "
"training script")
# rest from the training program
parser.add_argument('training_script_args', nargs=REMAINDER)
return parser.parse_args()
示例14: build_parser
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import REMAINDER [as 别名]
def build_parser(parser) -> ArgumentParser:
builders.build_config(parser)
builders.build_venv(parser)
builders.build_output(parser)
builders.build_other(parser)
parser.add_argument('--command', help='command to run')
parser.add_argument('name', nargs=REMAINDER, help='executable name to create')
return parser
示例15: build_parser
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import REMAINDER [as 别名]
def build_parser(parser) -> ArgumentParser:
builders.build_config(parser)
builders.build_from(parser)
builders.build_output(parser)
builders.build_venv(parser)
builders.build_other(parser)
parser.add_argument('name', nargs=REMAINDER, help='paths to install')
return parser