Quote:
Originally Posted by DiapDealer
Modifying a file in an ePub archive with python is certainly possible, but it can be tricky and more than a bit convoluted. Python's standard ZipFile module can read an archive contents; it can add files to archives; and it can create new archives. What it can't do is modify a file in an archive directly, or delete a file from an archive, or overwrite it.
You'd basically have to extract the contents of the ePub archive (maybe to a temp directory) first, then modify (overwrite/copy/rename/whatever) the css file(s) and then create a new zipfile from the modified, extracted content of the original (making sure to add the mimetype file first and uncompressed so it's a valid epub).
|
With the Calibre editor, I can export a stylesheet, then with the script I modify it and I import the modified file to replace the original stylesheet. Long to explain but technically very easy.
I was hoping I could somewhat modify directly the stylesheet. If this is not possible with a plain solution, I will propose the script to Kovid Goyal to include it within the many functions of his nice editor.