Skip to content

Commit 17e143f

Browse files
committed
add missing string cases
1 parent b2e4cff commit 17e143f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

servicestack/utils.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,26 @@ def camelcase(string):
2727
return lowercase(string[0]) + re.sub(r"[\-_\.\s]([a-z])", lambda matched: uppercase(matched.group(1)), string[1:])
2828

2929

30+
def capitalcase(string: str):
31+
string = str(string)
32+
if not string:
33+
return string
34+
return uppercase(string[0]) + string[1:]
35+
36+
37+
def pascalcase(string: str): return capitalcase(camelcase(string))
38+
39+
40+
def titlecase(string): return ' '.join([capitalcase(word) for word in snakecase(string).split("_")])
41+
42+
43+
def clean_camelcase(key: str):
44+
use_key = camelcase(key)
45+
if use_key[-1] == '_':
46+
use_key = use_key[0:-1]
47+
return use_key
48+
49+
3050
def ex_message(e: Exception):
3151
if hasattr(e, 'message'):
3252
return e.message

0 commit comments

Comments
 (0)