本文整理汇总了Python中argparse.MetavarTypeHelpFormatter方法的典型用法代码示例。如果您正苦于以下问题:Python argparse.MetavarTypeHelpFormatter方法的具体用法?Python argparse.MetavarTypeHelpFormatter怎么用?Python argparse.MetavarTypeHelpFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类argparse
的用法示例。
在下文中一共展示了argparse.MetavarTypeHelpFormatter方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: view_area_command
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import MetavarTypeHelpFormatter [as 别名]
def view_area_command(sub_parsers):
parser: ArgumentParser = sub_parsers.add_parser(
"view-area",
help="View information about an area.",
formatter_class=argparse.MetavarTypeHelpFormatter
)
add_data_file_argument(parser)
parser.add_argument(
"--simplify",
action="store_true",
help="Simplify the RequirementSets"
)
parser.add_argument(
"world",
type=str,
help="The name of the world that contains the area."
)
parser.add_argument(
"area",
type=str,
help="The name of the area."
)
parser.set_defaults(func=view_area_command_logic)
示例2: create_convert_database_command
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import MetavarTypeHelpFormatter [as 别名]
def create_convert_database_command(sub_parsers):
parser: ArgumentParser = sub_parsers.add_parser(
"convert-database",
help="Converts a database file between JSON and binary encoded formats. Input defaults to embedded database.",
formatter_class=argparse.MetavarTypeHelpFormatter
)
add_data_file_argument(parser)
parser.add_argument(
"--decode-to-game-description",
action="store_true",
default=False,
help="Decodes the input data to a GameDescription, then encodes it back."
)
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
"--output-binary",
type=Path,
help="Export as a binary file.",
)
group.add_argument(
"--output-json",
type=Path,
help="Export as a JSON file.",
)
parser.set_defaults(func=convert_database_command_logic)
示例3: export_areas_command
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import MetavarTypeHelpFormatter [as 别名]
def export_areas_command(sub_parsers):
parser: ArgumentParser = sub_parsers.add_parser(
"export-areas",
help="Export a text file with all areas and their requirements",
formatter_class=argparse.MetavarTypeHelpFormatter
)
add_data_file_argument(parser)
parser.add_argument("output_file", type=Path)
parser.set_defaults(func=export_areas_command_logic)
示例4: list_paths_with_dangerous_command
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import MetavarTypeHelpFormatter [as 别名]
def list_paths_with_dangerous_command(sub_parsers):
parser: ArgumentParser = sub_parsers.add_parser(
"list-dangerous-usage",
help="List all connections that needs a resource to be missing.",
formatter_class=argparse.MetavarTypeHelpFormatter
)
add_data_file_argument(parser)
parser.add_argument("--print-only-area", help="Only print the area names, not each specific path",
action="store_true")
parser.set_defaults(func=list_paths_with_dangerous_logic)
示例5: list_paths_with_difficulty_command
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import MetavarTypeHelpFormatter [as 别名]
def list_paths_with_difficulty_command(sub_parsers):
parser: ArgumentParser = sub_parsers.add_parser(
"list-difficulty-usage",
help="List all connections that needs the difficulty.",
formatter_class=argparse.MetavarTypeHelpFormatter
)
add_data_file_argument(parser)
parser.add_argument("--print-only-area", help="Only print the area names, not each specific path",
action="store_true")
parser.add_argument("difficulty", type=int)
parser.set_defaults(func=list_paths_with_difficulty_logic)
示例6: main
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import MetavarTypeHelpFormatter [as 别名]
def main():
import argparse
class MyFormatter(argparse.ArgumentDefaultsHelpFormatter, argparse.MetavarTypeHelpFormatter):
pass
parser = argparse.ArgumentParser(
formatter_class=MyFormatter,
description='Command line tool for training potential model with PiNN.')
parser.add_argument('--model-dir', type=str, required=True,
help='model directory')
parser.add_argument('--params-file', type=str, required=True,
help='path to parameters (.yml file)')
parser.add_argument('--train-data', type=str, required=True,
help='path to training data (.yml file)')
parser.add_argument('--eval-data', type=str, required=True,
help='path to evaluation data (.yml file)')
parser.add_argument('--train-steps', type=int, required=True,
help='number of training steps')
parser.add_argument('--eval-steps', type=int,
help='number of evaluation steps', default=100)
parser.add_argument('--batch-size', type=int,
help='Batch size to batch, default to None - data already batched',
default=None)
parser.add_argument('--preprocess', type=bool,
help='Preprocess the data', default=False)
parser.add_argument('--scratch-dir', type=str,
help='If set in preprocess mode, save the processed dataset to \
scratch folder', default=None)
parser.add_argument('--cache-data', type=bool,
help='cache the training data to memory', default=True)
parser.add_argument('--shuffle-buffer', type=int,
help='size of shuffle buffer', default=100)
parser.add_argument('--regen-dress', type=bool,
help='regenerate atomic dress using the training set', default=True)
args = parser.parse_args()
trainner(args.model_dir, args.params_file,
args.train_data, args.eval_data,
args.train_steps, args.eval_steps,
args.batch_size, args.preprocess,
args.scratch_dir, args.cache_data,
args.shuffle_buffer, args.regen_dress)
示例7: get_args
# 需要导入模块: import argparse [as 别名]
# 或者: from argparse import MetavarTypeHelpFormatter [as 别名]
def get_args():
"""Get command line arguments
"""
epoch_time = int(time.time())
report_filename = "report_{}_{}.csv".format(time.strftime("%Y-%m-%d_%H%M"), epoch_time)
parser = argparse.ArgumentParser(
description='Compare DNS server responses.',formatter_class=argparse.MetavarTypeHelpFormatter)
parser.add_argument('-o', type=str, default=report_filename, help='Report file name')
parser.add_argument('-c', type=str, help='hpHosts feed (Default: PSH)', choices=['PSH', 'EMD', 'EXP'], default='PSH')
parser.add_argument('-n', type=int, help='Number of hishing sites to test (Default: 500)', default=500)
parser.add_argument('-s', type=int, help='Shell type: set to 1 if spinner errors occur (default: 0)', default=0)
args = parser.parse_args()
return args