Implement #4214 (Sorting MANIFEST files in ePUB conversion)

This commit is contained in:
Kovid Goyal 2009-12-14 15:53:57 -07:00
parent 1c1b73d312
commit 4b413dfef3
2 changed files with 6 additions and 3 deletions

View File

@ -1206,8 +1206,12 @@ class Manifest(object):
return elem
def to_opf2(self, parent=None):
def sort(x, y):
return cmp(x.href, y.href)
elem = element(parent, OPF('manifest'))
for item in self.items:
for item in sorted(self.items, cmp=sort):
media_type = item.media_type
if media_type in OEB_DOCS:
media_type = XHTML_MIME
@ -1435,7 +1439,6 @@ class Guide(object):
return elem
# TODO: This needs beefing up to support the interface of toc.TOC
class TOC(object):
"""Represents a hierarchical table of contents or navigation tree for
accessing arbitrary semantic sections within an OEB data model book.

View File

@ -167,7 +167,7 @@ class FlowSplitter(object):
self.csp_counter = 0
base, ext = os.path.splitext(self.base)
self.base = base.replace('%', '%%')+'_split_%d'+ext
self.base = base.replace('%', '%%')+'_split_%.3d'+ext
self.trees = [self.item.data.getroottree()]
self.splitting_on_page_breaks = True