From ea01492e1fb70815d844c266f73ac2fa223a098c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Thu, 10 Oct 2013 13:17:03 +0200 Subject: [PATCH] Slugify: Unicode fix --- kcc/comic2ebook.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index deb4be8..421f19e 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -587,8 +587,11 @@ def getWorkFolder(afile): def slugify(value): # Normalizes string, converts to lowercase, removes non-alpha characters and converts spaces to hyphens. import unicodedata - #noinspection PyArgumentList - value = unicodedata.normalize('NFKD', unicode(value, 'latin1')).encode('ascii', 'ignore') + if isinstance(value, str): + #noinspection PyArgumentList + value = unicodedata.normalize('NFKD', unicode(value, 'latin1')).encode('ascii', 'ignore') + elif isinstance(value, unicode): + value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore') value = re.sub('[^\w\s\.-]', '', value).strip().lower() value = re.sub('[-\.\s]+', '-', value) value = re.sub(r'([0-9]+)', r'00000\1', value)