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