Further restriction of possible file names, due to NAS issues

This commit is contained in:
Remy Moll 2022-11-04 15:35:59 +01:00
parent 9e257f12a1
commit 24b3bc3b51
2 changed files with 9 additions and 4 deletions

View File

@ -9,3 +9,4 @@ htmldate
markdown markdown
rich rich
psycopg2 psycopg2
unidecode

View File

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