mirror of
https://github.com/ciromattia/kcc
synced 2025-12-17 19:51:45 +00:00
Slugify: Unicode fix
This commit is contained in:
@@ -587,8 +587,11 @@ def getWorkFolder(afile):
|
|||||||
def slugify(value):
|
def slugify(value):
|
||||||
# Normalizes string, converts to lowercase, removes non-alpha characters and converts spaces to hyphens.
|
# Normalizes string, converts to lowercase, removes non-alpha characters and converts spaces to hyphens.
|
||||||
import unicodedata
|
import unicodedata
|
||||||
#noinspection PyArgumentList
|
if isinstance(value, str):
|
||||||
value = unicodedata.normalize('NFKD', unicode(value, 'latin1')).encode('ascii', 'ignore')
|
#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('[^\w\s\.-]', '', value).strip().lower()
|
||||||
value = re.sub('[-\.\s]+', '-', value)
|
value = re.sub('[-\.\s]+', '-', value)
|
||||||
value = re.sub(r'([0-9]+)', r'00000\1', value)
|
value = re.sub(r'([0-9]+)', r'00000\1', value)
|
||||||
|
|||||||
Reference in New Issue
Block a user