def read(self):
file_path = os.path.join("db","alert.json")
if os.path.exists(file_path):
file_object = open(file_path,mode='r',encoding='utf-8')
data_dict = json.load(file_object)
file_object.close()
return data_dict
return {}
def write(self):
data_dict = {}
for key,filed in self.field_dict.items():
value = filed.text().strip()
if not value:
pass
data_dict[key] = value
file_object = open(os.path.join('db','alert.json'),mode ='w',encoding='utf-8')
json.dump(data_dict,file_object)
file_object.close()

def read_txt(self, path):
if os.path.exists(path):
with open(path, mode='r', encoding='utf-8') as f:
return f.read()
return ''

def write_txt(self, path, text):
with open(path, mode='w', encoding='utf-8') as f:
f.write(text)