mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
a15d236830
commit
c64783797e
@ -98,6 +98,9 @@ _self_closing_pat = re.compile(
|
|||||||
def close_self_closing_tags(raw):
|
def close_self_closing_tags(raw):
|
||||||
return _self_closing_pat.sub(r'<\g<tag>\g<arg>></\g<tag>>', raw)
|
return _self_closing_pat.sub(r'<\g<tag>\g<arg>></\g<tag>>', raw)
|
||||||
|
|
||||||
|
def uuid_id():
|
||||||
|
return 'u'+unicode(uuid.uuid4())
|
||||||
|
|
||||||
def iterlinks(root, find_links_in_css=True):
|
def iterlinks(root, find_links_in_css=True):
|
||||||
'''
|
'''
|
||||||
Iterate over all links in a OEB Document.
|
Iterate over all links in a OEB Document.
|
||||||
@ -1528,7 +1531,7 @@ class TOC(object):
|
|||||||
if parent is None:
|
if parent is None:
|
||||||
parent = etree.Element(NCX('navMap'))
|
parent = etree.Element(NCX('navMap'))
|
||||||
for node in self.nodes:
|
for node in self.nodes:
|
||||||
id = node.id or unicode(uuid.uuid4())
|
id = node.id or uuid_id()
|
||||||
po = node.play_order
|
po = node.play_order
|
||||||
if po == 0:
|
if po == 0:
|
||||||
po = 1
|
po = 1
|
||||||
@ -1634,10 +1637,10 @@ class PageList(object):
|
|||||||
return self.pages.remove(page)
|
return self.pages.remove(page)
|
||||||
|
|
||||||
def to_ncx(self, parent=None):
|
def to_ncx(self, parent=None):
|
||||||
plist = element(parent, NCX('pageList'), id=str(uuid.uuid4()))
|
plist = element(parent, NCX('pageList'), id=uuid_id())
|
||||||
values = dict((t, count(1)) for t in ('front', 'normal', 'special'))
|
values = dict((t, count(1)) for t in ('front', 'normal', 'special'))
|
||||||
for page in self.pages:
|
for page in self.pages:
|
||||||
id = page.id or unicode(uuid.uuid4())
|
id = page.id or uuid_id()
|
||||||
type = page.type
|
type = page.type
|
||||||
value = str(values[type].next())
|
value = str(values[type].next())
|
||||||
attrib = {'id': id, 'value': value, 'type': type, 'playOrder': '0'}
|
attrib = {'id': id, 'value': value, 'type': type, 'playOrder': '0'}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user