diff options
Diffstat (limited to 'configlib/util.py')
-rw-r--r-- | configlib/util.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/configlib/util.py b/configlib/util.py index 3c7618d..f325f25 100644 --- a/configlib/util.py +++ b/configlib/util.py @@ -1,8 +1,18 @@ +""" +Utility methods. Should not be imported from outside of :module:`configlib` +""" + import re from typing import List def parse_case(any_case: str) -> List[str]: + """ + parses a multiword string from cases like PascalCase or snake_case + + :param any_case: the multi-word string + :return: the words lowercased as an array + """ if '_' in any_case: return any_case.lower().split('_') if '-' in any_case: @@ -11,8 +21,20 @@ def parse_case(any_case: str) -> List[str]: def snake_case(any_case: str) -> str: + """ + parses a multiword string from cases like PascalCase or snake_case + + :param any_case: the multi-word string + :return: the words in snake_case + """ return '_'.join(parse_case(any_case)) def pascal_case(any_case: str) -> str: + """ + parses a multiword string from cases like PascalCase or snake_case + + :param any_case: the multi-word string + :return: the words in PascalCase + """ return ''.join(word.capitalize() for word in parse_case(any_case)) |