From dfb04b10525f75829c7df12281bd055803a45791 Mon Sep 17 00:00:00 2001 From: Eric_Lee Date: Mon, 15 Apr 2024 16:53:26 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=92=8C=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=20(#101)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/util/file_util.py | 6 ++---- apps/smartdoc/conf.py | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/apps/common/util/file_util.py b/apps/common/util/file_util.py index f46c460a7..447b007bc 100644 --- a/apps/common/util/file_util.py +++ b/apps/common/util/file_util.py @@ -9,8 +9,6 @@ def get_file_content(path): - file = open(path, "r", - encoding='utf-8') - content = file.read() - file.close() + with open(path, "r", encoding='utf-8') as file: + content = file.read() return content diff --git a/apps/smartdoc/conf.py b/apps/smartdoc/conf.py index 855b507a1..162971f48 100644 --- a/apps/smartdoc/conf.py +++ b/apps/smartdoc/conf.py @@ -193,11 +193,11 @@ class ConfigManager: if manager.load_from_yml(): config = manager.config else: - msg = """ + msg = f""" Error: No config file found. - You can run `cp config_example.yml config_example.yml`, and edit it. + You can run `cp config_example.yml {root_path}/config_example.yml`, and edit it. """ raise ImportError(msg) return config