From 692022e3b3eb682255db69a49538b56e792bbcae Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 12 Jan 2017 09:33:19 +0530 Subject: [PATCH] E-book Edit: Fix importing DOCX file as new book not setting the version attribute in the OPF --- src/calibre/ebooks/metadata/opf2.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/calibre/ebooks/metadata/opf2.py b/src/calibre/ebooks/metadata/opf2.py index e8fc502622..50e3b35091 100644 --- a/src/calibre/ebooks/metadata/opf2.py +++ b/src/calibre/ebooks/metadata/opf2.py @@ -37,6 +37,8 @@ class PrettyPrint(object): def __exit__(self, *args): global pretty_print_opf pretty_print_opf = False + + pretty_print = PrettyPrint() @@ -1570,6 +1572,7 @@ class OPFCreator(Metadata): guide ) root.set('unique-identifier', __appname__+'_id') + root.set('version', '2.0') raw = etree.tostring(root, pretty_print=True, xml_declaration=True, encoding=encoding) raw = raw.replace(DNS, OPF2_NS) @@ -1835,6 +1838,7 @@ def test_user_metadata(): assert um == opf2._user_metadata_ print opf.render() + if __name__ == '__main__': # test_user_metadata() test_m2o()