Created
September 22, 2018 03:01
-
-
Save ciscorn/644491c9be4ae36f88185069a9abb5c2 to your computer and use it in GitHub Desktop.
EPUBの見開き方向を right-to-left (縦書き用) に変える
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from zipfile import ZipFile | |
import lxml.etree as et | |
for path in sys.argv[1:]: | |
zf = ZipFile(path, mode='a') | |
with zf.open('OEBPS/content.opf', mode='r') as f: | |
doc = et.parse(f) | |
spine = doc.find('.//{http://www.idpf.org/2007/opf}spine') | |
print(spine.get("page-progression-direction")) | |
spine.set("page-progression-direction", "rtl") | |
with zf.open('OEBPS/content.opf', mode='w') as f: | |
f.write(et.tostring(doc, encoding='utf-8', pretty_print=True)) | |
zf.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment