From 87b72a571d06a72c1217eb375f29a56cfc361673 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 27 Jan 2022 15:32:58 +0700 Subject: [PATCH] simplify reading json files --- tubearchivist/home/src/es/index_setup.py | 3 +-- tubearchivist/home/src/ta/config.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tubearchivist/home/src/es/index_setup.py b/tubearchivist/home/src/es/index_setup.py index 4bb980b..8b0ed97 100644 --- a/tubearchivist/home/src/es/index_setup.py +++ b/tubearchivist/home/src/es/index_setup.py @@ -399,8 +399,7 @@ class ElasticBackup: def get_mapping(): """read index_mapping.json and get expected mapping and settings""" with open("home/src/es/index_mapping.json", "r", encoding="utf-8") as f: - config_str = f.read() - index_config = json.loads(config_str).get("index_config") + index_config = json.load(f).get("index_config") return index_config diff --git a/tubearchivist/home/src/ta/config.py b/tubearchivist/home/src/ta/config.py index 509e651..3258ed0 100644 --- a/tubearchivist/home/src/ta/config.py +++ b/tubearchivist/home/src/ta/config.py @@ -38,8 +38,7 @@ class AppConfig: def get_config_file(self): """read the defaults from config.json""" with open("home/config.json", "r", encoding="utf-8") as f: - config_str = f.read() - config_file = json.loads(config_str) + config_file = json.load(f) config_file["application"].update(self.get_config_env())