mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #509 (Fix for composite column sorting problem …)
This commit is contained in:
parent
09242c8f7a
commit
f915daed36
@ -8,14 +8,13 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
from locale import atof
|
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
from collections import defaultdict, Counter
|
from collections import defaultdict, Counter
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from calibre.db.tables import ONE_ONE, MANY_ONE, MANY_MANY, null
|
from calibre.db.tables import ONE_ONE, MANY_ONE, MANY_MANY, null
|
||||||
from calibre.db.write import Writer
|
from calibre.db.write import Writer
|
||||||
from calibre.db.utils import force_to_bool
|
from calibre.db.utils import force_to_bool, atof
|
||||||
from calibre.ebooks.metadata import title_sort, author_to_author_sort
|
from calibre.ebooks.metadata import title_sort, author_to_author_sort
|
||||||
from calibre.utils.config_base import tweaks
|
from calibre.utils.config_base import tweaks
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
|
@ -7,12 +7,13 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
import os, errno, cPickle, sys, re
|
import os, errno, cPickle, sys, re
|
||||||
|
from locale import localeconv
|
||||||
from collections import OrderedDict, namedtuple
|
from collections import OrderedDict, namedtuple
|
||||||
from future_builtins import map
|
from future_builtins import map
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
from calibre import as_unicode, prints
|
from calibre import as_unicode, prints
|
||||||
from calibre.constants import cache_dir
|
from calibre.constants import cache_dir, get_windows_number_formats, iswindows
|
||||||
|
|
||||||
def force_to_bool(val):
|
def force_to_bool(val):
|
||||||
if isinstance(val, (str, unicode)):
|
if isinstance(val, (str, unicode)):
|
||||||
@ -356,5 +357,20 @@ class ThumbnailCache(object):
|
|||||||
if hasattr(self, 'total_size'):
|
if hasattr(self, 'total_size'):
|
||||||
self._apply_size()
|
self._apply_size()
|
||||||
|
|
||||||
|
number_separators = None
|
||||||
|
def atof(string):
|
||||||
|
# Python 2.x does not handle unicode number separators correctly, so we
|
||||||
|
# have to implement our own
|
||||||
|
global number_separators
|
||||||
|
if number_separators is None:
|
||||||
|
if iswindows:
|
||||||
|
number_separators = get_windows_number_formats()
|
||||||
|
else:
|
||||||
|
lc = localeconv()
|
||||||
|
t, d = lc['thousands_sep'], lc['decimal_point']
|
||||||
|
if isinstance(t, bytes):
|
||||||
|
t = t.decode('utf-8', 'ignore') or ','
|
||||||
|
if isinstance(d, bytes):
|
||||||
|
d = d.decode('utf-8', 'ignore') or '.'
|
||||||
|
number_separators = t, d
|
||||||
|
return float(string.replace(number_separators[1], '.').replace(number_separators[0], ''))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user