Simplified changeCase function
This commit is contained in:
parent
73358d1c22
commit
613c1aebd3
|
@ -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:
|
|
||||||
res = string.upper()
|
|
||||||
return res
|
|
||||||
else:
|
else:
|
||||||
return string
|
return str
|
||||||
|
|
||||||
|
|
||||||
def getIDFromLink(link, type):
|
def getIDFromLink(link, type):
|
||||||
|
|
Loading…
Reference in New Issue