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
def load(self): try: with safe_open(self.path, "r") as rf: return json.load(rf) except FileNotFoundError: return []