1
Fork 0
mirror of https://github.com/RGBCube/JsonWrapper synced 2025-07-27 11:47:45 +00:00

Update db.py

This commit is contained in:
RGBCube 2022-01-12 21:42:56 +03:00 committed by GitHub
parent e8dc229458
commit 5f5e1cf802
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

4
db.py
View file

@ -21,13 +21,13 @@ class ClutterDB:
json_data[key] = value
json.dump(json_data, json_file, indent=4)
def get(self, key: str, **kwargs):
def get(self, key: str, *, default=None):
with open(self.path_to_json, mode="r") as json_file:
json_data = json.load(json_file)
if key in json_data:
return json_data[key]
else:
return kwargs.get("default", None)
return default
def all(self):
with open(self.path_to_json, mode="r") as json_file: