forked from 0x2620/pandora
sort_string, sorted_strings moved to ox
This commit is contained in:
parent
e4f635066e
commit
f09e4205cf
1 changed files with 1 additions and 11 deletions
|
@ -5,6 +5,7 @@ from decimal import Decimal
|
||||||
import re
|
import re
|
||||||
import unicodedata
|
import unicodedata
|
||||||
import ox
|
import ox
|
||||||
|
from ox import sorted_strings, sort_string
|
||||||
|
|
||||||
def safe_filename(filename):
|
def safe_filename(filename):
|
||||||
filename = filename.replace(': ', '_ ')
|
filename = filename.replace(': ', '_ ')
|
||||||
|
@ -46,17 +47,6 @@ def plural_key(term):
|
||||||
'country': 'countries',
|
'country': 'countries',
|
||||||
}.get(term, term + 's')
|
}.get(term, term + 's')
|
||||||
|
|
||||||
|
|
||||||
def sort_string(string):
|
|
||||||
string = string.replace(u'Æ', 'AE').replace(u'Ø', 'O').replace(u'Þ', 'Th')
|
|
||||||
|
|
||||||
#pad numbered titles
|
|
||||||
string = re.sub('(\d+)', lambda x: '%010d' % int(x.group(0)), string)
|
|
||||||
return unicodedata.normalize('NFKD', string)
|
|
||||||
|
|
||||||
def sorted_strings(strings):
|
|
||||||
return sorted(strings, cmp=lambda a, b: cmp(sort_string(a), sort_string(b)))
|
|
||||||
|
|
||||||
def sort_title(title):
|
def sort_title(title):
|
||||||
|
|
||||||
title = title.replace(u'Æ', 'Ae')
|
title = title.replace(u'Æ', 'Ae')
|
||||||
|
|
Loading…
Reference in a new issue