Beispiel #1
0
    def get_flag(cls):
        """
        Return the short and the long version of this option.

        The long flag (e.g. 'foo_bar'; used on the command-line like this:
        --foo_bar[=ARGS]) is derived from the class-name by stripping away any
        -Option suffix and converting the rest to snake_case.

        The short flag (e.g. 'f'; used on the command-line like this:
        -f [ARGS]) the short_flag class-member if that is set, or the first
        letter of the long flag otherwise.

        :return: tuple of short-flag, and long-flag
        :rtype: (str, str)
        """
        # Get the flag name from the class name
        flag = cls.__name__
        if flag.endswith("Option"):
            flag = flag[:-6]
        flag = convert_camel_case_to_snake_case(flag)

        if cls.short_flag is None:
            return flag[:1], flag
        else:
            return cls.short_flag, flag
Beispiel #2
0
def test_convert_camel_case_to_snake_case(name, expected):
    assert convert_camel_case_to_snake_case(name) == expected
Beispiel #3
0
def test_convert_camel_case_to_snake_case(name, expected):
    assert convert_camel_case_to_snake_case(name) == expected
Beispiel #4
0
 def get_flag(cls):
     # Get the flag name from the class name
     flag = cls.__name__
     if flag.endswith("Option"):
         flag = flag[:-6]
     return '--' + convert_camel_case_to_snake_case(flag)
Beispiel #5
0
 def get_flag(cls):
     # Get the flag name from the class name
     flag = cls.__name__
     if flag.endswith("Option"):
         flag = flag[:-6]
     return '--' + convert_camel_case_to_snake_case(flag)