rta_to_lstchain_formator.utils.rta_argparse.EnumAction¶
- class rta_to_lstchain_formator.utils.rta_argparse.EnumAction(**kwargs)[source]¶
Bases:
Action
Argparse action for handling Enums
Allows to show help with the enum values as choices, while returning an Enum value once the argument is parsed.
The implementation is copied from this answer on slackoverflow: https://stackoverflow.com/a/60750535
Examples
>>> class MyEnum(Enum): >>> Foo = "foo" >>> Bar = "bar" >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--my_enum', type=MyEnum, action=EnumAction) >>> parser.print_help() # prints --my_enum {foo,bar}
Methods
__init__
(**kwargs)format_usage
()