Ejemplo n.º 1
0
def test_kebab_case():
    assert kebab_case('aCamelCasedString') == 'a-camel-cased-string'
    assert kebab_case('A_snake_cased_string') == 'a-snake-cased-string'
    assert kebab_case('A-kebab-cased-string') == 'a-kebab-cased-string'
    assert kebab_case('A normal sentence') == 'a-normal-sentence'
    assert kebab_case('_an underscore-prefix') == '-an-underscore-prefix'
    assert kebab_case('__a private-prefix') == '--a-private-prefix'
    assert kebab_case('FoobarAPIController') == 'foobar-api-controller'
    assert kebab_case('') == ''
    assert kebab_case(None) is None
Ejemplo n.º 2
0
    def get_value(self, meta, base_classes_meta, mcs_args: McsArgs):
        value = super().get_value(meta, base_classes_meta, mcs_args)
        if (value is not _missing or mcs_args.Meta.abstract
                or not mcs_args.Meta.model):
            return value

        return '/' + pluralize(kebab_case(mcs_args.Meta.model.__name__))
Ejemplo n.º 3
0
def method_name_to_url(method_name) -> str:
    """
    Converts a method name to a url.
    """
    return '/' + kebab_case(method_name).strip('-')
Ejemplo n.º 4
0
def method_name_to_url(method_name) -> str:
    return '/' + kebab_case(method_name).strip('-')
Ejemplo n.º 5
0
def watchlist(fn):
    setattr(fn, '__watchlist__', kebab_case(fn.__name__))
    return fn