Quote:
Originally Posted by BeckyEbook
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.