Refactored helpers.py into a folder of various util files

This commit is contained in:
Grant Sanderson
2018-03-30 18:19:23 -07:00
parent 4de2dd1d5a
commit 8fae39fe82
75 changed files with 1009 additions and 911 deletions

19
utils/strings.py Normal file
View File

@ -0,0 +1,19 @@
import re
import string
def to_camel_case(name):
return "".join([
filter(
lambda c : c not in string.punctuation + string.whitespace, part
).capitalize()
for part in name.split("_")
])
def initials(name, sep_values = [" ", "_"]):
return "".join([
(s[0] if s else "")
for s in re.split("|".join(sep_values), name)
])
def camel_case_initials(name):
return filter(lambda c : c.isupper(), name)