Exemplo n.º 1
0
def verify_output_choice(choice):
    """
    Function that verifies output choice is a supported OutputFormat.

    :param choice:    String representing an OutputFormat
    :return: str:     String representing an OutputFormat
    """
    options = OutputFormat.list()

    if choice not in options:
        error_message = f'Not a valid output option: "{choice}"'
        raise argparse.ArgumentTypeError(error_message)

    return options[options.index(choice)]
Exemplo n.º 2
0
    """
    options = OutputFormat.list()

    if choice not in options:
        error_message = f'Not a valid output option: "{choice}"'
        raise argparse.ArgumentTypeError(error_message)

    return options[options.index(choice)]


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='Near Earth Objects (NEOs) Database')
    parser.add_argument(
        'output',
        choices=OutputFormat.list(),
        type=verify_output_choice,
        help='Select option for how to output the search results.')
    parser.add_argument('-r',
                        '--return_object',
                        choices=['NEO', 'Path'],
                        default='NEO',
                        type=str,
                        help='Select entity data to return.')
    parser.add_argument(
        '-d',
        '--date',
        type=verify_date,
        help='YYYY-MM-DD format to find NEOs on the given date')
    parser.add_argument(
        '-s',
Exemplo n.º 3
0
    :param choice:    String representing an OutputFormat
    :return: str:     String representing an OutputFormat
    """
    options = OutputFormat.list()

    if choice not in options:
        error_message = "Not a valid output option:"+ choice
        raise argparse.ArgumentTypeError(error_message)

    return options[options.index(choice)]


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='Near Earth Objects (NEOs) Database')
    parser.add_argument('output', choices=OutputFormat.list(), type=verify_output_choice,
                        help='Select option for how to output the search results.')
    parser.add_argument('-r', '--return_object', choices=['NEO', 'Path'],
                        default='NEO', type=str,
                        help='Select entity data to return.')
    parser.add_argument('-d', '--date', type=verify_date,
                        help='YYYY-MM-DD format to find NEOs on the given date')
    parser.add_argument('-s', '--start_date', type=verify_date,
                        help='YYYY-MM-DD format to find NEOs on the provided start date')
    parser.add_argument('-e', '--end_date', type=verify_date,
                        help='YYYY-MM-DD format to find NEOs up to the end date')
    parser.add_argument('-n', '--number', type=int,
                        help='Int representing max number of NEOs to return')
    parser.add_argument('-f', '--filename', type=str,
                        help='Name of input csv data file')
    parser.add_argument('--filter', nargs='+', help='Select filter options with filter value: '