View Single Post
Old 06-05-2014, 03:25 PM   #5
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,692
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
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's 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).

Last edited by DiapDealer; 06-05-2014 at 03:37 PM.
DiapDealer is offline   Reply With Quote