fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Some tests for various API endpoints.
[wolnelektury.git]
/
src
/
sortify.py
diff --git
a/src/sortify.py
b/src/sortify.py
index
642a540
..
61cb9d8
100644
(file)
--- a/
src/sortify.py
+++ b/
src/sortify.py
@@
-1,6
+1,6
@@
# -*- coding: utf-8 -*-
import re
# -*- coding: utf-8 -*-
import re
-from fnpdjango.utils.text
.slughifi
import char_map
+from fnpdjango.utils.text import char_map
# Specifies diacritics order.
# Specifies diacritics order.
@@
-12,7
+12,7
@@
char_order = {
def replace_char(m):
char = m.group()
def replace_char(m):
char = m.group()
- if char
_map.has_key(char)
:
+ if char
in char_map
:
order = char_order.get(char, 0)
return "%s~%d" % (char_map[char], order)
else:
order = char_order.get(char, 0)
return "%s~%d" % (char_map[char], order)
else:
@@
-37,7
+37,7
@@
def sortify(value):
value = unicode(value, 'utf-8')
# try to replace chars
value = unicode(value, 'utf-8')
# try to replace chars
- value = re.sub('[^a-zA-Z0-9\\s\\-]
{1}
', replace_char, value)
+ value = re.sub('[^a-zA-Z0-9\\s\\-]', replace_char, value)
value = value.lower()
value = re.sub(r'[^a-z0-9~]+', ' ', value)
value = value.lower()
value = re.sub(r'[^a-z0-9~]+', ' ', value)