Commit 0daa360789314f084a89a5c5edaabe34024571da
1 parent
957dc282
Exists in
master
and in
20 other branches
Fix unicode error using normalize_name
Signed-off-by: Gustavo Jaruga <darksshades@gmail.com> Signed-off-by: Macartur Sousa <macartur.sc@gmail.com> Signed-off-by: Matheus Faria <matheus.sousa.faria@gmail.com> Signed-off-by: Matheus Fernandes <msfernandes@gmail.com>
Showing
1 changed file
with
8 additions
and
5 deletions
Show diff stats
src/colab-spb-plugin/src/colab_spb/tasks.py
1 | 1 | import requests |
2 | -import unicodedata | |
2 | +from unicodedata import normalize, category | |
3 | 3 | |
4 | 4 | from django.conf import settings |
5 | 5 | |
... | ... | @@ -17,10 +17,13 @@ def normalize_name(name): |
17 | 17 | all letters |
18 | 18 | """ |
19 | 19 | name = name.replace(' ', '-') |
20 | - name = ''.join(c for c in unicodedata.normalize('NFD', unicode( | |
21 | - name, 'utf-8')) if unicodedata.category(c) != 'Mn') | |
22 | - name = name.lower() | |
23 | - return name | |
20 | + | |
21 | + if not isinstance(name, unicode): | |
22 | + name = unicode(name, 'utf-8') | |
23 | + | |
24 | + name = ''.join(c for c in normalize('NFD', name) if category(c) != 'Mn') | |
25 | + | |
26 | + return name.lower() | |
24 | 27 | |
25 | 28 | |
26 | 29 | def create_group_from_community(noosfero_community): | ... | ... |
-
mentioned in commit df898d9582c58713eb6c2ac60c55b536108ce2ac