diff options
author | romangraef <romangraef@loves.dicksinhisan.us> | 2018-07-11 15:35:46 +0200 |
---|---|---|
committer | romangraef <romangraef@loves.dicksinhisan.us> | 2018-07-11 15:38:05 +0200 |
commit | e71aa06a9a1ea1e58aa192353622d40791f751d4 (patch) | |
tree | 183f0fa309056b432c253f604d6ff6ffd6f27594 /configlib/util.py | |
parent | cbb9f2c3622ec96caf4ec9e58e84c8fbd3f45d23 (diff) | |
download | configlib-e71aa06a9a1ea1e58aa192353622d40791f751d4.tar.gz configlib-e71aa06a9a1ea1e58aa192353622d40791f751d4.tar.bz2 configlib-e71aa06a9a1ea1e58aa192353622d40791f751d4.zip |
cleaning up docs + type hints
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)) |