aboutsummaryrefslogtreecommitdiff
path: root/configlib/util.py
blob: 3c7618d219d03c75d1d72d8fc65ed26d643dbc3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import re
from typing import List


def parse_case(any_case: str) -> List[str]:
    if '_' in any_case:
        return any_case.lower().split('_')
    if '-' in any_case:
        return any_case.lower().split('-')
    return [word.lower() for word in re.split('(?<=[a-z0-9])(?=[A-Z])', any_case)]


def snake_case(any_case: str) -> str:
    return '_'.join(parse_case(any_case))


def pascal_case(any_case: str) -> str:
    return ''.join(word.capitalize() for word in parse_case(any_case))