Implement dumping for odt in addition to docx

This commit is contained in:
Kovid Goyal 2014-03-29 15:38:15 +05:30
parent 30bbd17481
commit 2a333aa46a
2 changed files with 7 additions and 6 deletions

View File

@ -279,10 +279,10 @@ def main(args=sys.argv):
main(['calibre-diff'] + args[1:])
elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'py', 'recipe'}:
run_script(args[1], args[2:])
elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'mobi', 'azw', 'azw3', 'docx'}:
elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'mobi', 'azw', 'azw3', 'docx', 'odt'}:
for path in args[1:]:
ext = path.rpartition('.')[-1]
if ext == 'docx':
if ext in {'docx', 'odt'}:
from calibre.ebooks.docx.dump import dump
dump(path)
elif ext in {'mobi', 'azw', 'azw3'}:

View File

@ -25,6 +25,7 @@ def dump(path):
if f.endswith('.xml') or f.endswith('.rels'):
with open(f, 'r+b') as stream:
raw = stream.read()
if raw:
root = etree.fromstring(raw)
stream.seek(0)
stream.truncate()