mirror of
https://github.com/RGBCube/JsonWrapper
synced 2025-07-27 19:57:44 +00:00
Update db.py
This commit is contained in:
parent
0691d234dd
commit
d86daf3aca
1 changed files with 1 additions and 5 deletions
6
db.py
6
db.py
|
@ -58,10 +58,7 @@ class ClutterDB:
|
||||||
self.utils.validate_json(self.path_to_json)
|
self.utils.validate_json(self.path_to_json)
|
||||||
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 pathmagic == "":
|
return json_data.get(key, default) if pathmagic == "" else return self.utils.path_magic_get(json_data, pathmagic, key=key, default=default)
|
||||||
return json_data.get(key, default)
|
|
||||||
else:
|
|
||||||
return self.utils.path_magic_get(json_data, pathmagic, key=key, default=default)
|
|
||||||
|
|
||||||
def all(self):
|
def all(self):
|
||||||
self.utils.validate_json(self.path_to_json)
|
self.utils.validate_json(self.path_to_json)
|
||||||
|
@ -77,6 +74,5 @@ class ClutterDB:
|
||||||
json.dump(json_data, json_file, indent=4)
|
json.dump(json_data, json_file, indent=4)
|
||||||
|
|
||||||
def nuke(self):
|
def nuke(self):
|
||||||
self.utils.validate_json(self.path_to_json)
|
|
||||||
with open(self.path_to_json, mode="w") as json_file:
|
with open(self.path_to_json, mode="w") as json_file:
|
||||||
json.dump({}, json_file)
|
json.dump({}, json_file)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue