From 9a6b212ec4e29fff3b1174643e8e266475e36efd Mon Sep 17 00:00:00 2001 From: j Date: Mon, 12 Jun 2017 17:00:32 +0200 Subject: [PATCH] move all non ascii first letters into _ --- oml/item/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/oml/item/models.py b/oml/item/models.py index ee6f2c1..704d603 100644 --- a/oml/item/models.py +++ b/oml/item/models.py @@ -9,6 +9,7 @@ import shutil import stat import unicodedata import time +import string import ox from sqlalchemy.orm import load_only @@ -772,6 +773,8 @@ class File(db.Model): title = '%s (%s)' % (title, extra.strip()) filename = '%s.%s' % (title, extension) first = unicodedata.normalize('NFD', author[0].upper())[0].upper() + if first not in string.ascii_uppercase: + first = '_' new_path = os.path.join(first, author, filename) new_path = new_path.replace('\x00', '') new_path = new_path.replace('\n', ' ').replace(' ', ' ')