Ui improvment

This commit is contained in:
2023-03-17 22:55:06 +01:00
parent c518ccf2b4
commit 3e8cfec634
3 changed files with 70 additions and 11 deletions
+20
View File
@@ -54,6 +54,26 @@ def norm_str(string, separator='_', format=str.lower, padding=0):
return string
def norm_name(string, separator='_', format=str.lower, padding=0):
string = str(string)
string = string.split('/')[-1] #used to remove first slash -> albert / albert_casque -> albert_casque
string = string.replace('_', ' ')
string = string.replace('-', ' ')
string = re.sub('[ ]+', ' ', string)
string = re.sub('[ ]+\/[ ]+', '/', string)
string = string.strip()
if format:
string = format(string)
# Padd rightest number
string = re.sub(r'(\d+)(?!.*\d)', lambda x : x.group(1).zfill(padding), string)
string = string.replace(' ', separator)
string = unicodedata.normalize('NFKD', string).encode('ASCII', 'ignore').decode("utf-8")
return string
def read_file(path):
'''Read a file with an extension in (json, yaml, yml, txt)'''