Python argparse.MetavarTypeHelpFormatter() Examples

The following are 7 code examples for showing how to use argparse.MetavarTypeHelpFormatter(). 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 want to check out the right sidebar which shows the related API usage.

You may also want to check out all available functions/classes of the module argparse , or try the search function .

Example 1
Project: randovania   Author: randovania   File: prime_database.py    License: GNU General Public License v3.0 6 votes vote down vote up
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) 
Example 2
Project: randovania   Author: randovania   File: prime_database.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 3
Project: randovania   Author: randovania   File: prime_database.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 4
Project: randovania   Author: randovania   File: prime_database.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 5
Project: randovania   Author: randovania   File: prime_database.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 6
Project: PiNN   Author: Teoroo-CMC   File: trainer.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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) 
Example 7
Project: dingoes   Author: cryptoaustralia   File: dingoes.py    License: MIT License 5 votes vote down vote up
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