Python argparse.REMAINDER Examples
The following are 30 code examples for showing how to use argparse.REMAINDER(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
argparse
, or try the search function
.
Example 1
Project: mx Author: graalvm File: mx_ideconfig.py License: GNU General Public License v2.0 | 6 votes |
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([])
Example 2
Project: pwnypack Author: edibledinos File: main.py License: MIT License | 6 votes |
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)
Example 3
Project: bob Author: BobBuildTool File: archive.py License: GNU General Public License v3.0 | 6 votes |
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))
Example 4
Project: ros2cli Author: ros2 File: run.py License: Apache License 2.0 | 6 votes |
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')
Example 5
Project: cinch Author: RedHatQE File: entry_point.py License: GNU General Public License v3.0 | 6 votes |
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)
Example 6
Project: armory Author: depthsecurity File: DomLink.py License: GNU General Public License v3.0 | 6 votes |
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", )
Example 7
Project: pytorch_image_classification Author: hysts File: train.py License: MIT License | 6 votes |
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
Example 8
Project: Collaborative-Learning-for-Weakly-Supervised-Object-Detection Author: Sunarker File: test_net.py License: MIT License | 5 votes |
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
Example 9
Project: Collaborative-Learning-for-Weakly-Supervised-Object-Detection Author: Sunarker File: trainval_net.py License: MIT License | 5 votes |
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
Example 10
Project: mx Author: graalvm File: mx_ide_intellij.py License: GNU General Public License v2.0 | 5 votes |
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)
Example 11
Project: PoseWarper Author: facebookresearch File: test.py License: Apache License 2.0 | 5 votes |
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
Example 12
Project: PoseWarper Author: facebookresearch File: train.py License: Apache License 2.0 | 5 votes |
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
Example 13
Project: OpenChem Author: Mariewelt File: launch.py License: MIT License | 5 votes |
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()
Example 14
Project: dephell Author: dephell File: venv_entrypoint.py License: MIT License | 5 votes |
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
Example 15
Project: dephell Author: dephell File: project_register.py License: MIT License | 5 votes |
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
Example 16
Project: dephell Author: dephell File: jail_install.py License: MIT License | 5 votes |
def build_parser(parser) -> ArgumentParser: builders.build_config(parser) builders.build_venv(parser) builders.build_resolver(parser) builders.build_output(parser) builders.build_other(parser) parser.add_argument('name', nargs=REMAINDER, help='packages to install') return parser
Example 17
Project: dephell Author: dephell File: package_install.py License: MIT License | 5 votes |
def build_parser(parser) -> ArgumentParser: builders.build_config(parser) builders.build_resolver(parser) builders.build_venv(parser) builders.build_output(parser) builders.build_other(parser) parser.add_argument('name', nargs=REMAINDER, help='package to install') return parser
Example 18
Project: dephell Author: dephell File: generate_license.py License: MIT License | 5 votes |
def build_parser(parser) -> ArgumentParser: builders.build_config(parser) builders.build_output(parser) builders.build_other(parser) parser.add_argument('--owner', help='name of the owner') parser.add_argument('name', nargs=REMAINDER, help='license name') return parser
Example 19
Project: dephell Author: dephell File: docker_prepare.py License: MIT License | 5 votes |
def build_parser(parser) -> ArgumentParser: builders.build_config(parser) builders.build_docker(parser) builders.build_output(parser) builders.build_other(parser) parser.add_argument('name', nargs=REMAINDER, help='command to run') return parser
Example 20
Project: dephell Author: dephell File: deps_tree.py License: MIT License | 5 votes |
def build_parser(parser) -> ArgumentParser: builders.build_config(parser) builders.build_from(parser) builders.build_resolver(parser) builders.build_api(parser) builders.build_output(parser) builders.build_other(parser) parser.add_argument('--type', choices=('pretty', 'json', 'graph'), default='pretty', help='format for tree output.') parser.add_argument('name', nargs=REMAINDER, help='package to get dependencies from') return parser
Example 21
Project: dephell Author: dephell File: package_changelog.py License: MIT License | 5 votes |
def build_parser(parser) -> ArgumentParser: builders.build_config(parser) builders.build_venv(parser) builders.build_output(parser) builders.build_api(parser) builders.build_other(parser) parser.add_argument('name', nargs=REMAINDER, help='package name') return parser
Example 22
Project: dephell Author: dephell File: package_search.py License: MIT License | 5 votes |
def build_parser(parser) -> ArgumentParser: builders.build_config(parser) builders.build_output(parser) builders.build_api(parser) builders.build_other(parser) parser.add_argument('name', nargs=REMAINDER, help='package name or other search keywords') return parser
Example 23
Project: dephell Author: dephell File: jail_try.py License: MIT License | 5 votes |
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 execute.') parser.add_argument('name', nargs=REMAINDER, help='packages to install') return parser
Example 24
Project: dephell Author: dephell File: project_test.py License: MIT License | 5 votes |
def build_parser(parser) -> ArgumentParser: builders.build_config(parser) builders.build_from(parser) builders.build_venv(parser) builders.build_output(parser) builders.build_other(parser) parser.add_argument('name', nargs=REMAINDER, help='command to run') return parser
Example 25
Project: ChromaTerm Author: hSaria File: cli.py License: MIT License | 5 votes |
def args_init(args=None): """Returns the parsed arguments (an instance of argparse.Namespace). Args: args (list): A list of program arguments, Defaults to sys.argv. """ parser = argparse.ArgumentParser() parser.add_argument('program', type=str, metavar='program ...', nargs='?', help='run a program with anything after it used as ' 'arguments') parser.add_argument('arguments', type=str, nargs=argparse.REMAINDER, help=argparse.SUPPRESS, default=[]) parser.add_argument('--config', metavar='FILE', type=str, help='location of config file (default: %(default)s)', default='$HOME/.chromaterm.yml') parser.add_argument('--reload', action='store_true', help='Reload the config of all CT instances') parser.add_argument('--rgb', action='store_true', help='Use RGB colors (default: detect support, ' 'fallback to xterm-256)', default=None) return parser.parse_args(args=args)
Example 26
Project: SegmenTron Author: LikeLy-Journey File: options.py License: Apache License 2.0 | 5 votes |
def parse_args(): parser = argparse.ArgumentParser(description='Segmentron') parser.add_argument('--config-file', metavar="FILE", help='config file path') # cuda setting parser.add_argument('--no-cuda', action='store_true', default=False, help='disables CUDA training') parser.add_argument('--local_rank', type=int, default=0) # checkpoint and log parser.add_argument('--resume', type=str, default=None, help='put the path to resuming file if needed') parser.add_argument('--log-iter', type=int, default=10, help='print log every log-iter') # for evaluation parser.add_argument('--val-epoch', type=int, default=1, help='run validation every val-epoch') parser.add_argument('--skip-val', action='store_true', default=False, help='skip validation during training') # for visual parser.add_argument('--input-img', type=str, default='tools/demo_vis.png', help='path to the input image or a directory of images') # config options parser.add_argument('opts', help='See config for all options', default=None, nargs=argparse.REMAINDER) args = parser.parse_args() return args
Example 27
Project: pytorch-FPN Author: yxgeee File: test_net.py License: MIT License | 5 votes |
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
Example 28
Project: pytorch-FPN Author: yxgeee File: trainval_net.py License: MIT License | 5 votes |
def parse_args(): """ Parse input arguments """ parser = argparse.ArgumentParser(description='Train a Fast R-CNN network') 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('--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
Example 29
Project: GTDWeb Author: lanbing510 File: runfcgi.py License: GNU General Public License v2.0 | 5 votes |
def add_arguments(self, parser): parser.add_argument('args', nargs=argparse.REMAINDER, help='Various KEY=val options.')
Example 30
Project: bob Author: BobBuildTool File: jenkins.py License: GNU General Public License v3.0 | 5 votes |
def doJenkins(argv, bobRoot): subHelp = "\n ... ".join(sorted( [ "{} {}".format(c, d[1]) for (c, d) in availableJenkinsCmds.items() ])) parser = argparse.ArgumentParser(prog="bob jenkins", formatter_class=argparse.RawDescriptionHelpFormatter, description="""Configure jenkins. The following subcommands are available: bob jenkins {} """.format(subHelp)) parser.add_argument('subcommand', help="Subcommand") parser.add_argument('args', nargs=argparse.REMAINDER, help="Arguments for subcommand") parser.add_argument('-c', dest="configFile", default=[], action='append', metavar="NAME", help="Use additional config File.") args = parser.parse_args(argv) recipes = RecipeSet() recipes.defineHook('jenkinsNameFormatter', jenkinsNameFormatter) recipes.setConfigFiles(args.configFile) recipes.parse() if args.subcommand in availableJenkinsCmds: BobState().setAsynchronous() try: availableJenkinsCmds[args.subcommand][0](recipes, args.args) except urllib.error.HTTPError as e: raise BuildError("HTTP error: " + str(e)) except OSError as e: raise BuildError("OS error: " + str(e)) finally: BobState().setSynchronous() else: parser.error("Unknown subcommand '{}'".format(args.subcommand))