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-17 18:23:39 +03:00 committed by GitHub
parent 0691d234dd
commit d86daf3aca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

6
db.py
View file

@ -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)