simplify reading json files

This commit is contained in:
simon 2022-01-27 15:32:58 +07:00
parent 00e9e4bc53
commit 87b72a571d
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 2 additions and 4 deletions

View File

@ -399,8 +399,7 @@ class ElasticBackup:
def get_mapping(): def get_mapping():
"""read index_mapping.json and get expected mapping and settings""" """read index_mapping.json and get expected mapping and settings"""
with open("home/src/es/index_mapping.json", "r", encoding="utf-8") as f: with open("home/src/es/index_mapping.json", "r", encoding="utf-8") as f:
config_str = f.read() index_config = json.load(f).get("index_config")
index_config = json.loads(config_str).get("index_config")
return index_config return index_config

View File

@ -38,8 +38,7 @@ class AppConfig:
def get_config_file(self): def get_config_file(self):
"""read the defaults from config.json""" """read the defaults from config.json"""
with open("home/config.json", "r", encoding="utf-8") as f: with open("home/config.json", "r", encoding="utf-8") as f:
config_str = f.read() config_file = json.load(f)
config_file = json.loads(config_str)
config_file["application"].update(self.get_config_env()) config_file["application"].update(self.get_config_env())