mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix for weird type error passing sys.maxsize to xrange
This commit is contained in:
parent
33bb570277
commit
2bdf7f7508
@ -23,7 +23,7 @@ from calibre.utils.localization import get_lang, canonicalize_lang
|
|||||||
from calibre import prints, guess_type
|
from calibre import prints, guess_type
|
||||||
from calibre.utils.cleantext import clean_ascii_chars, clean_xml_chars
|
from calibre.utils.cleantext import clean_ascii_chars, clean_xml_chars
|
||||||
from calibre.utils.config import tweaks
|
from calibre.utils.config import tweaks
|
||||||
from polyglot.builtins import iteritems, unicode_type, range
|
from polyglot.builtins import iteritems, unicode_type
|
||||||
from polyglot.urllib import unquote, urlparse
|
from polyglot.urllib import unquote, urlparse
|
||||||
|
|
||||||
pretty_print_opf = False
|
pretty_print_opf = False
|
||||||
@ -712,16 +712,16 @@ class OPF(object): # {{{
|
|||||||
return self.manifest_path(self.root)
|
return self.manifest_path(self.root)
|
||||||
|
|
||||||
def create_manifest_item(self, href, media_type, append=False):
|
def create_manifest_item(self, href, media_type, append=False):
|
||||||
ids = [i.get('id', None) for i in self.itermanifest()]
|
ids = {i.get('id', None) for i in self.itermanifest()}
|
||||||
id = None
|
manifest_id = 'id1'
|
||||||
for c in range(1, sys.maxsize):
|
c = 1
|
||||||
id = 'id%d'%c
|
while manifest_id not in ids:
|
||||||
if id not in ids:
|
c += 1
|
||||||
break
|
manifest_id = 'id%d'%c
|
||||||
if not media_type:
|
if not media_type:
|
||||||
media_type = 'application/xhtml+xml'
|
media_type = 'application/xhtml+xml'
|
||||||
ans = etree.Element('{%s}item'%self.NAMESPACES['opf'],
|
ans = etree.Element('{%s}item'%self.NAMESPACES['opf'],
|
||||||
attrib={'id':id, 'href':href, 'media-type':media_type})
|
attrib={'id':manifest_id, 'href':href, 'media-type':media_type})
|
||||||
ans.tail = '\n\t\t'
|
ans.tail = '\n\t\t'
|
||||||
if append:
|
if append:
|
||||||
manifest = self.manifest_ppath(self.root)[0]
|
manifest = self.manifest_ppath(self.root)[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user