View Single Post
Old 01-21-2018, 04:12 PM   #282
BeckyEbook
Guru
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 876
Karma: 3501146
Join Date: Jan 2017
Location: Poland
Device: Various
Again me: Validate OPF and offset.
I found the issue that bothered me.

bk.get_opf() -- is not perfect.

Why?
Result of bk.get_opf() is not current state of file .opf. This is state "what will the .opf file look like after saving" + missing two spaces before <metadata and </metadata> + missing four spaces before each <dc:… and <meta ….

These missing spaces prevented me from calculating the offsets accurately.
Code:
    opf_data = bk.get_opf()
    opf_data = re.sub("<metadata","  <metadata",opf_data)
    opf_data = re.sub("<meta ","    <meta ",opf_data)
    opf_data = re.sub("<dc:","    <dc:",opf_data)
    opf_data = re.sub("</metadata","  </metadata",opf_data)
BeckyEbook is offline   Reply With Quote