예제 #1
0
 def __init__(
     self,
     default: Union[None, _T, Iterable[_T]],
     enum_values: Iterable[_T],
     help_string: Optional[str] = None,
 ):
     parser = _argument_parsers.MultiEnumParser(enum_values)
     serializer = flags.ArgumentSerializer()
     _ = parser.parse(enum_values)
     super().__init__(default, help_string, parser, serializer)
예제 #2
0
def DEFINE_multi_enum(  # pylint: disable=invalid-name,redefined-builtin
        name,
        default,
        enum_values,
        help,
        flag_values=flags.FLAGS,
        **args):
    """Defines flag for MultiEnum."""
    parser = _argument_parsers.MultiEnumParser(enum_values)
    serializer = flags.ArgumentSerializer()
    # usage_logging: multi_enum
    flags.DEFINE(parser, name, default, help, flag_values, serializer, **args)
예제 #3
0
def DEFINE_multi_enum(  # pylint: disable=invalid-name,redefined-builtin
    name: str,
    default: Optional[Iterable[_T]],
    enum_values: Iterable[_T],
    help: str,
    flag_values=flags.FLAGS,
    **args,
) -> flags.FlagHolder[_T]:
    """Defines flag for MultiEnum."""
    parser = _argument_parsers.MultiEnumParser(enum_values)
    serializer = flags.ArgumentSerializer()
    # usage_logging: multi_enum
    return flags.DEFINE(
        parser,
        name,
        default,
        help,
        flag_values,
        serializer,
        **args,
    )
예제 #4
0
 def setUp(self):
   super().setUp()
   self.parser = _argument_parsers.MultiEnumParser(
       ["a", "a", ["a"], "b", "c", 1, [2], {
           "a": "d"
       }])
예제 #5
0
 def __init__(self, default, enum_values, help_string):
     parser = _argument_parsers.MultiEnumParser(enum_values)
     serializer = flags.ArgumentSerializer()
     _ = parser.parse(enum_values)
     super().__init__(default, help_string, parser, serializer)