Ui improvment
This commit is contained in:
@@ -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)'''
|
||||
|
||||
|
||||
Reference in New Issue
Block a user