14 lines
480 B
Python

import unidecode
KEEPCHARACTERS = (' ','.','_', '-')
def clear_path_name(path):
path = unidecode.unidecode(path) # remove umlauts, accents and others
path = "".join([c if (c.isalnum() or c in KEEPCHARACTERS) else "_" for c in path]) # remove all non-alphanumeric characters
path = path.rstrip() # remove trailing spaces
return path
def shorten_name(name, offset = 50):
if len(name) > offset:
return name[:offset] + "..."
else:
return name