Simplified changeCase function

This commit is contained in:
RemixDev 2020-07-29 12:03:03 +02:00
parent 73358d1c22
commit 613c1aebd3
1 changed files with 7 additions and 18 deletions

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import re import re
import string
def getBitrateInt(txt): def getBitrateInt(txt):
@ -20,29 +21,17 @@ def getBitrateInt(txt):
return None return None
def changeCase(string, type): def changeCase(str, type):
if type == "lower": if type == "lower":
return string.lower() return str.lower()
elif type == "upper": elif type == "upper":
return string.upper() return str.upper()
elif type == "start": elif type == "start":
string = string.split(" ") return string.capwords(str)
res = []
for index, value in enumerate(string):
if len(value) > 2:
res.append(value[0].upper() + value[1:].lower())
else:
res.append(value.upper())
res = " ".join(res)
return res
elif type == "sentence": elif type == "sentence":
if len(string) > 2: return str.capitalize()
res = string[0].upper() + string[1:].lower()
else: else:
res = string.upper() return str
return res
else:
return string
def getIDFromLink(link, type): def getIDFromLink(link, type):