I tried this:
Code:
tdir = PersistentTemporaryDirectory('_PrincePDF')
exploder = get_tools(format)[0]
opf = exploder(book, tdir)
#os.chdir(os.path.dirname(opf))
oeb = OEBBook(default_log, HTMLPreProcessor, CSSPreProcessor)
OEBReader()(oeb, opf)
(where "format" and "book" are arguments passed to the function".) The exploding seems to go fine, if I print the "tdir" value I can see that the directory is created and all the ePub files are there. I have tried with and without the chdir, but I always get:
Code:
Failed to parse content in Chapitre-36.xhtml
Failed to parse content in Chapitre-14.xhtml
Failed to parse content in Chapitre-21.xhtml
[...]
Referenced file u'Chapitre-24.xhtml' not in manifest
Referenced file u'Chapitre-12.xhtml' not in manifest
Referenced file u'Chapitre-10.xhtml' not in manifest
[...]
OEBError: Spine is empty
What am I doing wrong so far?
EDIT: Solved, I had to use preprocessor instances:
Code:
html_preprocessor = HTMLPreProcessor()
css_preprocessor = CSSPreProcessor()
oeb = OEBBook(default_log, html_preprocessor, css_preprocessor)
Now the unused files are not removed from the manifest, but the metadata does not correspond to the OPF (illustrator or translator do not appear, neither do <meta> tags). In my tool I was using "import xml.dom.minidom", is that safe to use within a calibre plugin? Is there any alternative?