fix: gitignore & rw

This commit is contained in:
Didier Slof 2022-12-09 11:07:55 +01:00
parent 2b5e72460a
commit c01124844d
Signed by: didier
GPG key ID: 01E71F18AA4398E5
2 changed files with 3 additions and 3 deletions

2
.gitignore vendored
View file

@ -2,4 +2,4 @@
*.tar.gz *.tar.gz
.idea .idea
.vscode .vscode
__pycharm__ __pycache__

View file

@ -10,14 +10,14 @@ class SaveFile(dict):
if not os.path.exists(_dir): if not os.path.exists(_dir):
os.makedirs(_dir) os.makedirs(_dir)
if os.path.exists(self.path): if os.path.exists(self.path):
with open(self.path, 'w+') as f: with open(self.path, 'r') as f:
self.update(json.loads(f.read())) self.update(json.loads(f.read()))
else: else:
self.save() self.save()
def save(self): def save(self):
with open(self.path, 'w+') as f: with open(self.path, 'w+') as f:
f.write(json.dumps(self, indent=1)) f.write(json.dumps(self))
def __getitem__(self, key): def __getitem__(self, key):
return super().__getitem__(key) return super().__getitem__(key)