示例#1
0
def DEFINE_list(  # pylint: disable=invalid-name,redefined-builtin
        name,
        default,
        help,
        flag_values=_flagvalues.FLAGS,
        **args):
    """Registers a flag whose value is a comma-separated list of strings.

  The flag value is parsed with a CSV parser.

  Args:
    name: str, the flag name.
    default: list|str|None, the default value of the flag.
    help: str, the help message.
    flag_values: FlagValues, the FlagValues instance with which the flag will be
      registered. This should almost never need to be overridden.
    **args: Dictionary with extra keyword args that are passed to the Flag
      __init__.

  Returns:
    a handle to defined flag.
  """
    parser = _argument_parser.ListParser()
    serializer = _argument_parser.CsvListSerializer(',')
    return DEFINE(parser, name, default, help, flag_values, serializer, **args)
示例#2
0
 def test_csv_serializer(self):
     serializer = _argument_parser.CsvListSerializer('+')
     self.assertEqual(serializer.serialize(['foo', 'bar']), 'foo+bar')