View Single Post
Old 01-21-2018, 04:34 PM   #283
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,705
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by BeckyEbook View Post
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)
Use:
Code:
opf_data = bk.readotherfile("OEBPS/content.opf")
if you want to make sure you get the current state of the opf.

bk.get_opf() is performing some parsing/rebuilding of the various sections of the opf.

Last edited by DiapDealer; 01-21-2018 at 04:44 PM.
DiapDealer is offline   Reply With Quote