fix: rw savefiles
This commit is contained in:
parent
82ce01b85b
commit
2b5e72460a
1 changed files with 2 additions and 2 deletions
|
@ -10,13 +10,13 @@ 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) as f:
|
with open(self.path, 'w+') 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, 'a+') as f:
|
with open(self.path, 'w+') as f:
|
||||||
f.write(json.dumps(self, indent=1))
|
f.write(json.dumps(self, indent=1))
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
|
|
Reference in a new issue