本文整理汇总了Python中argparse.RawDescriptionHelpFormatter方法的典型用法代码示例。如果您正苦于以下问题:Python argparse.RawDescriptionHelpFormatter方法的具体用法?Python argparse.RawDescriptionHelpFormatter怎么用?Python argparse.RawDescriptionHelpFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类argparse
的用法示例。
在下文中一共展示了argparse.RawDescriptionHelpFormatter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_arg_parser
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawDescriptionHelpFormatter [as 别名]
def build_arg_parser(description, env_vars={}):
from argparse import ArgumentParser, RawDescriptionHelpFormatter
from textwrap import dedent
base_env_vars = {
'MONO_SOURCE_ROOT': 'Overrides default value for --mono-sources',
}
env_vars_text = '\n'.join([' %s: %s' % (var, desc) for var, desc in env_vars.items()])
base_env_vars_text = '\n'.join([' %s: %s' % (var, desc) for var, desc in base_env_vars.items()])
epilog=dedent('''\
environment variables:
%s
%s
''' % (env_vars_text, base_env_vars_text))
return ArgumentParser(
description=description,
formatter_class=RawDescriptionHelpFormatter,
epilog=epilog
)
示例2: parse_args
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawDescriptionHelpFormatter [as 别名]
def parse_args(self):
parser = argparse.ArgumentParser(
description = self._description,
epilog = self._epilog,
formatter_class = argparse.RawDescriptionHelpFormatter,
usage = self._usage)
self._add_flags(parser)
self._add_export(parser)
### Print help message if no arguments are present.
if len(sys.argv[1:]) == 0:
parser.print_help()
raise SystemExit
args = parser.parse_args()
return args, parser
示例3: create_parser
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawDescriptionHelpFormatter [as 别名]
def create_parser():
parser = ArgumentParser(description=__doc__,
formatter_class=RawDescriptionHelpFormatter)
parser.add_argument('--debug', action='store_true')
parser.add_argument('--delimiter')
parser.add_argument('--embedding-size', default=200, type=int)
parser.add_argument('--graph-path')
parser.add_argument('--has-header', action='store_true')
parser.add_argument('--input', '-i', dest='infile', required=True)
parser.add_argument('--log-level', '-l', type=str.upper, default='INFO')
parser.add_argument('--num-walks', default=1, type=int)
parser.add_argument('--model', '-m', dest='model_path')
parser.add_argument('--output', '-o', dest='outfile', required=True)
parser.add_argument('--stats', action='store_true')
parser.add_argument('--undirected', action='store_true')
parser.add_argument('--walk-length', default=10, type=int)
parser.add_argument('--window-size', default=5, type=int)
parser.add_argument('--workers', default=multiprocessing.cpu_count(),
type=int)
return parser
示例4: create_parser
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawDescriptionHelpFormatter [as 别名]
def create_parser():
"""Set up parsing for command-line arguments
"""
parser = argparse.ArgumentParser(description=__doc__, # Use text from file summary up top
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('--reference-cluster-path',
dest='ref_cluster_path',
help='Path to SCP cluster file to use as reference ' +
'(i.e. normal, control) cells')
parser.add_argument('--reference-group-name',
dest='ref_group_name',
help='Name of cell group in SCP cluster file to use as ' +
'label for inferCNV references')
parser.add_argument('--metadata-path',
help='Path to SCP metadata file that contains all cells')
parser.add_argument('--observation-group-name',
dest='obs_group_name',
help='Name of the cell group in SCP metadata file to ' +
'use as label for observations')
parser.add_argument('--delimiter',
help='Delimiter in SCP cluster file',
default="\t")
parser.add_argument('--output-dir',
help='Path to write output')
return parser
示例5: _create_parser
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawDescriptionHelpFormatter [as 别名]
def _create_parser():
parser = ArgumentParser(description="Compare two tempest xml results",
formatter_class=RawDescriptionHelpFormatter)
parser.add_argument("result_1",
help="path to xml result 1")
parser.add_argument("result_2",
help="path to xml result 2")
'''TODO future functionality
parser.add_argument("-c", "--csv", dest="output_csv",
action="store_true",
help="output csv")
parser.add_argument("-m", "--html", dest="output_html",
action="store_true",
help="output html")
parser.add_argument("-n", "--json", dest="output_json",
action="store_true",
help="output json")
parser.add_argument("-o", "--output-file", dest="output_file",
type=str, required=False,
help="If specified, output will be saved to given "
"file")
'''
return parser
示例6: __init__
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawDescriptionHelpFormatter [as 别名]
def __init__(self, config='config.yaml', description=None):
super(BaseOptions, self).__init__()
logging.debug('BaseOptions.__init__')
self._ordered_keys = []
self._exclude_keys = set()
self._parent = argparse.ArgumentParser(add_help=False)
self._parser = argparse.ArgumentParser(parents=[self._parent],
description=description,
formatter_class=argparse.RawDescriptionHelpFormatter)
# config file option
self.config = config
# config file
self._parent.add_argument('--config', type=str, default=self.config, metavar=self.config,
help='configuration file name')
示例7: create_parser
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawDescriptionHelpFormatter [as 别名]
def create_parser(prog):
"""Create an argument parser, adding in the list of providers."""
parser = argparse.ArgumentParser(
prog=prog, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument(
'--provider',
default='google-v2',
choices=['local', 'google-v2', 'google-cls-v2', 'test-fails'],
help="""Job service provider. Valid values are "google-v2" (Google's
Pipeline API v2alpha1), "google-cls-v2" (Google's Pipelines API v2beta)
and "local" (local Docker execution).
"test-*" providers are for testing purposes only.
(default: google-v2)""",
metavar='PROVIDER')
return parser
示例8: _parse_cli_options
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawDescriptionHelpFormatter [as 别名]
def _parse_cli_options():
"""
Parse command line options, returning `parse_args` from `ArgumentParser`.
"""
parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter,
usage="python %(prog)s <options>",
epilog="example:\n"
"python %(prog)s -w workflow1 workflow2 -l my_panel_label\n"
"Christophe Antoniewski <drosofff@gmail.com>\n"
"https://github.com/ARTbio/ansible-artimed/tree/master/scritps/galaxykickstart_from_workflow.py")
parser.add_argument('-w', '--workflow',
dest="workflow_files",
required=True,
nargs='+',
help='A space-separated list of galaxy workflow description files in json format', )
parser.add_argument('-l', '--panel_label',
dest='panel_label',
default='Tools from workflows',
help='The name of the panel where the tools will show up in Galaxy.'
'If not specified: "Tools from workflows"')
return parser.parse_args()
示例9: create_parser
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawDescriptionHelpFormatter [as 别名]
def create_parser():
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description="learn BPE-based word segmentation")
parser.add_argument(
'--input', '-i', type=argparse.FileType('r'), default=sys.stdin,
metavar='PATH',
help="Input file (default: standard input).")
parser.add_argument(
'--codes', '-c', type=argparse.FileType('r'), metavar='PATH',
required=True,
help="File with BPE codes (created by learn_bpe.py).")
parser.add_argument(
'--output', '-o', type=argparse.FileType('w'), default=sys.stdout,
metavar='PATH',
help="Output file (default: standard output)")
parser.add_argument(
'--separator', '-s', type=str, default='@@', metavar='STR',
help="Separator between non-final subword units (default: '%(default)s'))")
return parser
示例10: create_parser
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawDescriptionHelpFormatter [as 别名]
def create_parser():
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description="learn BPE-based word segmentation")
parser.add_argument(
'--input', '-i', type=argparse.FileType('r'), default=sys.stdin,
metavar='PATH',
help="Input text (default: standard input).")
parser.add_argument(
'--output', '-o', type=argparse.FileType('w'), default=sys.stdout,
metavar='PATH',
help="Output file for BPE codes (default: standard output)")
parser.add_argument(
'--symbols', '-s', type=int, default=10000,
help="Create this many new symbols (each representing a character n-gram) (default: %(default)s))")
parser.add_argument(
'--min-frequency', type=int, default=2, metavar='FREQ',
help='Stop if no symbol pair has frequency >= FREQ (default: %(default)s))')
parser.add_argument(
'--verbose', '-v', action="store_true",
help="verbose mode.")
return parser
示例11: add_list_blocks_parser
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawDescriptionHelpFormatter [as 别名]
def add_list_blocks_parser(subparsers, parent_parser):
"""Creates the arg parsers needed for the compare command.
"""
parser = subparsers.add_parser(
'list-blocks',
help='List blocks from different nodes.',
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog='',
parents=[parent_parser, base_multinode_parser()])
parser.add_argument(
'-n',
'--count',
default=10,
type=int,
help='the number of blocks to list')
示例12: doArchive
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawDescriptionHelpFormatter [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))
示例13: run
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawDescriptionHelpFormatter [as 别名]
def run():
parser = argparse.ArgumentParser(description="""
The SafeLife command-line tool can be used to interactively play
a game of SafeLife, print procedurally generated SafeLife boards,
or convert saved boards to images for easy viewing.
Please select one of the available commands to run the program.
You can run `safelife <command> --help` to get more help on a
particular command.
""", formatter_class=argparse.RawDescriptionHelpFormatter)
subparsers = parser.add_subparsers(dest="cmd", help="Top-level command.")
interactive_game._make_cmd_args(subparsers)
render_graphics._make_cmd_args(subparsers)
args = parser.parse_args()
if args.cmd is None:
parser.print_help()
else:
args.run_cmd(args)
示例14: main
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawDescriptionHelpFormatter [as 别名]
def main():
""" Parse command line arguments and start exploit """
parser = argparse.ArgumentParser(
add_help=False,
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="Examples: %(prog)s -t http://192.168.0.1/ -u username -p password -c whoami")
# Adds arguments to help menu
parser.add_argument("-h", action="help", help="Print this help message then exit")
parser.add_argument("-t", dest="target", required="yes", help="Target URL address like: https://localhost:443/")
parser.add_argument("-u", dest="username", required="yes", help="Username to authenticate")
parser.add_argument("-p", dest="password", required="yes", help="Password to authenticate")
parser.add_argument("-c", dest="command", required="yes", help="Shell command to execute")
# Assigns the arguments to various variables
args = parser.parse_args()
run(args.target, args.username, args.password, args.command)
#
# Main
#
示例15: main
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import RawDescriptionHelpFormatter [as 别名]
def main():
import argparse
parser = argparse.ArgumentParser(description='Polls the kerberos service for a TGT for the sepcified user', formatter_class=argparse.RawDescriptionHelpFormatter, epilog = kerberos_url_help_epilog)
parser.add_argument('kerberos_connection_url', help='the kerberos target string. ')
parser.add_argument('ccache', help='ccache file to store the TGT ticket in')
parser.add_argument('-v', '--verbose', action='count', default=0)
args = parser.parse_args()
if args.verbose == 0:
logging.basicConfig(level=logging.INFO)
elif args.verbose == 1:
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig(level=1)
asyncio.run(amain(args))