mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implemented special case icu code for OS X 10.6.x in establish_equivalencies
This commit is contained in:
parent
a6f73264d6
commit
c17b43d8cb
@ -3,12 +3,13 @@
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Greg Riker'
|
__copyright__ = '2010, Greg Riker'
|
||||||
|
|
||||||
import datetime, htmlentitydefs, os, re, shutil, unicodedata, zlib
|
import datetime, htmlentitydefs, os, platform, re, shutil, unicodedata, zlib
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from xml.sax.saxutils import escape
|
from xml.sax.saxutils import escape
|
||||||
|
|
||||||
from calibre import (prepare_string_for_xml, strftime, force_unicode,
|
from calibre import (prepare_string_for_xml, strftime, force_unicode,
|
||||||
isbytestring)
|
isbytestring)
|
||||||
|
from calibre.constants import isosx
|
||||||
from calibre.customize.conversion import DummyReporter
|
from calibre.customize.conversion import DummyReporter
|
||||||
from calibre.customize.ui import output_profiles
|
from calibre.customize.ui import output_profiles
|
||||||
from calibre.ebooks.BeautifulSoup import BeautifulSoup, BeautifulStoneSoup, Tag, NavigableString
|
from calibre.ebooks.BeautifulSoup import BeautifulSoup, BeautifulStoneSoup, Tag, NavigableString
|
||||||
@ -643,12 +644,32 @@ class CatalogBuilder(object):
|
|||||||
c = item
|
c = item
|
||||||
|
|
||||||
ordnum, ordlen = collation_order(c)
|
ordnum, ordlen = collation_order(c)
|
||||||
if last_ordnum != ordnum:
|
if isosx and platform.mac_ver()[0] < '10.7':
|
||||||
last_c = icu_upper(c[0:ordlen])
|
# Hackhackhackhackhack
|
||||||
if last_c in exceptions.keys():
|
# icu returns bogus results with curly apostrophes, maybe others under OS X 10.6.x
|
||||||
last_c = exceptions[unicode(last_c)]
|
# When we see the magic combo of 0/-1 for ordnum/ordlen, special case the logic
|
||||||
last_ordnum = ordnum
|
if ordnum == 0 and ordlen == -1:
|
||||||
cl_list[idx] = last_c
|
if icu_upper(c[0]) != last_c:
|
||||||
|
last_c = icu_upper(c[0])
|
||||||
|
if last_c in exceptions.keys():
|
||||||
|
last_c = exceptions[unicode(last_c)]
|
||||||
|
last_ordnum = ordnum
|
||||||
|
cl_list[idx] = last_c
|
||||||
|
else:
|
||||||
|
if last_ordnum != ordnum:
|
||||||
|
last_c = icu_upper(c[0:ordlen])
|
||||||
|
if last_c in exceptions.keys():
|
||||||
|
last_c = exceptions[unicode(last_c)]
|
||||||
|
last_ordnum = ordnum
|
||||||
|
cl_list[idx] = last_c
|
||||||
|
|
||||||
|
else:
|
||||||
|
if last_ordnum != ordnum:
|
||||||
|
last_c = icu_upper(c[0:ordlen])
|
||||||
|
if last_c in exceptions.keys():
|
||||||
|
last_c = exceptions[unicode(last_c)]
|
||||||
|
last_ordnum = ordnum
|
||||||
|
cl_list[idx] = last_c
|
||||||
|
|
||||||
if self.DEBUG and self.opts.verbose:
|
if self.DEBUG and self.opts.verbose:
|
||||||
print(" establish_equivalencies():")
|
print(" establish_equivalencies():")
|
||||||
@ -656,7 +677,7 @@ class CatalogBuilder(object):
|
|||||||
for idx, item in enumerate(item_list):
|
for idx, item in enumerate(item_list):
|
||||||
print(" %s %s" % (cl_list[idx],item[sort_field]))
|
print(" %s %s" % (cl_list[idx],item[sort_field]))
|
||||||
else:
|
else:
|
||||||
print(" %s %s" % (cl_list[0], item))
|
print(" %s %s" % (cl_list[idx], item))
|
||||||
|
|
||||||
return cl_list
|
return cl_list
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user