merge with upstream master
This commit is contained in:
16
helix/helpers/camel_case.py
Normal file
16
helix/helpers/camel_case.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import re
|
||||
|
||||
|
||||
def convert_camel_case_to_snake_case(name):
|
||||
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
|
||||
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
|
||||
|
||||
|
||||
def convert_dict_keys_to_snake_case(a_dict):
|
||||
new_dict = {}
|
||||
for old_key in a_dict.keys():
|
||||
new_key = convert_camel_case_to_snake_case(old_key)
|
||||
new_dict[new_key] = a_dict[old_key]
|
||||
return new_dict
|
||||
|
||||
|
||||
Reference in New Issue
Block a user