mirror of
https://github.com/RGBCube/JsonWrapper
synced 2025-07-27 11:47:45 +00:00
Update db.py
This commit is contained in:
parent
e8dc229458
commit
5f5e1cf802
1 changed files with 2 additions and 2 deletions
4
db.py
4
db.py
|
@ -21,13 +21,13 @@ class ClutterDB:
|
||||||
json_data[key] = value
|
json_data[key] = value
|
||||||
json.dump(json_data, json_file, indent=4)
|
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:
|
with open(self.path_to_json, mode="r") as json_file:
|
||||||
json_data = json.load(json_file)
|
json_data = json.load(json_file)
|
||||||
if key in json_data:
|
if key in json_data:
|
||||||
return json_data[key]
|
return json_data[key]
|
||||||
else:
|
else:
|
||||||
return kwargs.get("default", None)
|
return default
|
||||||
|
|
||||||
def all(self):
|
def all(self):
|
||||||
with open(self.path_to_json, mode="r") as json_file:
|
with open(self.path_to_json, mode="r") as json_file:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue