From e6410c067b59e1976d2e1bd55fe26b376cf59014 Mon Sep 17 00:00:00 2001 From: noisyfox Date: Sat, 7 Jan 2017 21:10:49 +1100 Subject: [PATCH] Don't clear file first when saving config file --- mujson_mgr.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mujson_mgr.py b/mujson_mgr.py index a20a91f..ecf473b 100644 --- a/mujson_mgr.py +++ b/mujson_mgr.py @@ -27,8 +27,11 @@ class MuJsonLoader(object): def save(self, path): if self.json: output = json.dumps(self.json, sort_keys=True, indent=4, separators=(',', ': ')) - with open(path, 'wb') as f: + with open(path, 'a'): + pass + with open(path, 'r+') as f: f.write(output.encode('utf8')) + f.truncate() class MuMgr(object):