1
Fork 0
mirror of https://github.com/RGBCube/JsonWrapper synced 2025-07-27 19:57:44 +00:00

code simplification

This commit is contained in:
RGBCube 2022-01-14 16:28:35 +03:00 committed by GitHub
parent 6e7295262e
commit 961aa9ff57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

5
db.py
View file

@ -24,10 +24,7 @@ class ClutterDB:
def get(self, key: str, *, default=None): 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: return json_data.get(key, default)
return json_data[key]
else:
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: