From 55dc80cfbd16198c4772d2326c4d37afb0e628fe Mon Sep 17 00:00:00 2001 From: samuel b Date: Thu, 13 Feb 2020 15:37:33 +0100 Subject: [PATCH] modify json import / export json filename ':' replaced so accepted on Windows 'wb' modified to 'w' because json.dump(s) output is a string (sorry forgot a line :/) --- dirtools.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dirtools.py b/dirtools.py index e9f9c98..d5a683b 100644 --- a/dirtools.py +++ b/dirtools.py @@ -353,18 +353,19 @@ def to_json(self, base_path='.', dt=None, fmt=None): fmt = '{0}@{1}.json' if dt is None: dt = datetime.utcnow() + dt = dt.isoformat().replace(':','-') path = fmt.format(self._dir.path.strip('/').split('/')[-1], - dt.isoformat()) + dt) path = os.path.join(base_path, path) - with open(path, 'wb') as f: + with open(path, 'w') as f: f.write(json.dumps(self.state)) return path @classmethod def from_json(cls, path): - with open(path, 'rb') as f: + with open(path, 'r') as f: return cls(state=json.loads(f.read()))