Пример #1
0
 def json(self):
     try:
         with open(self.path) as rf:
             return json.load(rf)
     except FileNotFoundError:
         data = []
         with safe_open(self.path, "w") as wf:
             json.dump(data, wf)
         return data
Пример #2
0
 def load(self):
     try:
         with safe_open(self.path, "r") as rf:
             return json.load(rf)
     except FileNotFoundError:
         return []