fix: gitignore & rw
This commit is contained in:
parent
2b5e72460a
commit
c01124844d
2 changed files with 3 additions and 3 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,4 +2,4 @@
|
|||
*.tar.gz
|
||||
.idea
|
||||
.vscode
|
||||
__pycharm__
|
||||
__pycache__
|
|
@ -10,14 +10,14 @@ class SaveFile(dict):
|
|||
if not os.path.exists(_dir):
|
||||
os.makedirs(_dir)
|
||||
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()))
|
||||
else:
|
||||
self.save()
|
||||
|
||||
def save(self):
|
||||
with open(self.path, 'w+') as f:
|
||||
f.write(json.dumps(self, indent=1))
|
||||
f.write(json.dumps(self))
|
||||
|
||||
def __getitem__(self, key):
|
||||
return super().__getitem__(key)
|
||||
|
|
Reference in a new issue