~ubuntu-branches/debian/sid/calibre/sid

« back to all changes in this revision

Viewing changes to src/calibre/ebooks/oeb/polish/container.py

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2014-02-27 07:48:06 UTC
  • mto: This revision was merged to the branch mainline in revision 74.
  • Revision ID: package-import@ubuntu.com-20140227074806-64wdebb3ptosxhhx
Tags: upstream-1.25.0+dfsg
ImportĀ upstreamĀ versionĀ 1.25.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
171
171
            ans = 'application/xhtml+xml'
172
172
        return ans
173
173
 
174
 
    def add_file(self, name, data, media_type=None):
 
174
    def add_file(self, name, data, media_type=None, spine_index=None):
175
175
        ''' Add a file to this container. Entries for the file are
176
176
        automatically created in the OPF manifest and spine
177
177
        (if the file is a text document) '''
209
209
        if mt in OEB_DOCS:
210
210
            spine = self.opf_xpath('//opf:spine')[0]
211
211
            si = manifest.makeelement(OPF('itemref'), idref=item_id)
212
 
            self.insert_into_xml(spine, si)
 
212
            self.insert_into_xml(spine, si, index=spine_index)
213
213
 
214
214
    def rename(self, current_name, new_name):
215
215
        ''' Renames a file from current_name to new_name. It automatically
403
403
            data, strip_encoding_pats=True, assume_utf8=True, resolve_entities=True)
404
404
        return etree.fromstring(data, parser=RECOVER_PARSER)
405
405
 
406
 
    def parse_xhtml(self, data, fname='<string>'):
 
406
    def parse_xhtml(self, data, fname='<string>', force_html5_parse=False):
407
407
        if self.tweak_mode:
408
 
            return parse_html_tweak(data, log=self.log, decoder=self.decode)
 
408
            return parse_html_tweak(data, log=self.log, decoder=self.decode, force_html5_parse=force_html5_parse)
409
409
        else:
410
410
            try:
411
411
                return parse_html(
985
985
            f.write(guess_type('a.epub'))
986
986
        zip_rebuilder(self.root, outpath)
987
987
 
988
 
    @property
 
988
    @dynamic_property
989
989
    def path_to_ebook(self):
990
 
        return self.pathtoepub
 
990
        def fget(self):
 
991
            return self.pathtoepub
 
992
        def fset(self, val):
 
993
            self.pathtoepub = val
 
994
        return property(fget=fget, fset=fset)
991
995
 
992
996
# }}}
993
997
 
1097
1101
            outpath = self.pathtoazw3
1098
1102
        opf_to_azw3(self.name_path_map[self.opf_name], outpath, self.log)
1099
1103
 
1100
 
    @property
 
1104
    @dynamic_property
1101
1105
    def path_to_ebook(self):
1102
 
        return self.pathtoazw3
 
1106
        def fget(self):
 
1107
            return self.pathtoazw3
 
1108
        def fset(self, val):
 
1109
            self.pathtoazw3 = val
 
1110
        return property(fget=fget, fset=fset)
1103
1111
 
1104
1112
    @property
1105
1113
    def names_that_must_not_be_changed(self):