1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-01-15 08:04:10 +01:00

Fix for the missing open file mode.

This commit is contained in:
2020-06-17 17:40:20 +02:00
parent 1c04e7a4c7
commit b4b02a4893

View File

@@ -392,11 +392,13 @@ class XMLConfig(dict):
dpath = os.path.dirname(self.file_path)
if not os.path.exists(dpath):
os.makedirs(dpath, mode=constants_old.CONFIG_DIR_MODE)
with open(self.file_path) as f:
with open(self.file_path, 'w') as f:
raw = self.to_raw()
f.seek(0)
f.truncate()
f.write(raw)
# TODO(gryf): get rid of another proxy for json module which
# stubbornly insist on using bytes instead of unicode objects
f.write(raw.decode('utf-8'))
def __enter__(self):
self.no_commit = True