aboutsummaryrefslogtreecommitdiff
path: root/configlib/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'configlib/util.py')
-rw-r--r--configlib/util.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/configlib/util.py b/configlib/util.py
new file mode 100644
index 0000000..3c7618d
--- /dev/null
+++ b/configlib/util.py
@@ -0,0 +1,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))