From ea0277348bd75d3673eba1bcee539ad0cf51909e Mon Sep 17 00:00:00 2001 From: j Date: Sun, 8 Mar 2015 00:12:16 +0530 Subject: [PATCH] use first latin character if possible --- oml/item/models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/oml/item/models.py b/oml/item/models.py index d457042..38e6509 100644 --- a/oml/item/models.py +++ b/oml/item/models.py @@ -528,7 +528,8 @@ class File(db.Model): author = format_underscores(author) filename = '%s.%s' % (title, extension) - new_path = os.path.join(author[0].upper(), author, filename) + first = unicodedata.normalize('NFD', author[0].upper())[0].upper() + new_path = os.path.join(first, author, filename) new_path = new_path.replace('\x00', '') if self.path == new_path: return @@ -536,7 +537,8 @@ class File(db.Model): while os.path.exists(os.path.join(prefix, new_path)): h = self.sha1[:len(h)+1] filename = '%s.%s.%s' % (title, h, extension) - new_path = os.path.join(author[0].upper(), author, filename) + first = unicodedata.normalize('NFD', author[0].upper())[0].upper() + new_path = os.path.join(first, author, filename) if current_path == os.path.join(prefix, new_path): break if self.path != new_path: