1
Fork 0
mirror of https://github.com/RGBCube/JsonWrapper synced 2025-07-27 11:47:45 +00:00
This commit is contained in:
RGBCube 2022-01-12 21:24:03 +03:00 committed by GitHub
parent 58850a9c4a
commit 5b9e8796d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

7
db.py
View file

@ -31,12 +31,15 @@ class ClutterDB:
else:
return None
def all(self):
with open(self.path_to_json, mode="r") as json_file:
return json.load(json_file)
def rem(self, key: str):
with open(self.path_to_json, mode="r") as json_file:
json_data = json.load(json_file)
with open(self.path_to_json, mode="w") as json_file:
json_data.pop(key, None)
json.dump(json_data, json_file, indent=4)
json.dump(json_data.pop(key, None), json_file, indent=4)
def nuke(self):
with open(self.path_to_json, mode="w") as json_file: