View Single Post
Old 06-05-2014, 03:12 PM   #4
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 2,625
Karma: 3120635
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
Here is it. I do not have anything more than these lines. I wish I had.

Code:
#!/usr/bin/python

import sys, re

conv=2.37106301584
unit=re.compile('([^\d.]+:\s*)([\d.]+)(cm)?(;\s*)')
with open(sys.argv[1],'r') as f, open(sys.argv[2],'w') as g :
   for lig in f :
      k=unit.search(lig)
      if k :
         unite=k.group(3)
         if unite=='cm' :
            val="%.2f"%(conv*float(k.group(2)))
            unite='em'
            lig=k.group(1)+val+unite+k.group(4)
      g.write(lig)
I also had a script that had been given to me by Jellby to insert directly a file in META-INF without opening the EPUB. I thought that a similar process could be used here.

Code:
for i in *.epub; do zip "$i" META-INF/com.apple.ibooks.display-options.xml; done

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