mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix icu_collate sqlite function
This commit is contained in:
parent
b12e0123aa
commit
7ff5842e71
@ -18,8 +18,9 @@ from functools import partial
|
||||
from calibre.ebooks.metadata import title_sort, author_to_author_sort
|
||||
from calibre.utils.config import tweaks
|
||||
from calibre.utils.date import parse_date, isoformat
|
||||
from calibre import isbytestring
|
||||
from calibre import isbytestring, force_unicode
|
||||
from calibre.constants import iswindows, DEBUG
|
||||
from calibre.utils.icu import strcmp
|
||||
|
||||
global_lock = RLock()
|
||||
|
||||
@ -115,8 +116,8 @@ def pynocase(one, two, encoding='utf-8'):
|
||||
pass
|
||||
return cmp(one.lower(), two.lower())
|
||||
|
||||
def icu_collator(s1, s2, func=None):
|
||||
return cmp(func(unicode(s1)), func(unicode(s2)))
|
||||
def icu_collator(s1, s2):
|
||||
return strcmp(force_unicode(s1, 'utf-8'), force_unicode(s2, 'utf-8'))
|
||||
|
||||
def load_c_extensions(conn, debug=DEBUG):
|
||||
try:
|
||||
@ -169,8 +170,7 @@ class DBThread(Thread):
|
||||
self.conn.create_function('uuid4', 0, lambda : str(uuid.uuid4()))
|
||||
# Dummy functions for dynamically created filters
|
||||
self.conn.create_function('books_list_filter', 1, lambda x: 1)
|
||||
from calibre.utils.icu import sort_key
|
||||
self.conn.create_collation('icucollate', partial(icu_collator, func=sort_key))
|
||||
self.conn.create_collation('icucollate', icu_collator)
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user