From 153dbc0788470cc58a1d0e10fe7d3a499fe535c7 Mon Sep 17 00:00:00 2001 From: hayden Date: Wed, 6 Nov 2024 15:39:06 +0800 Subject: [PATCH] fix: issue saving differences across platforms --- py/download.py | 2 +- py/services.py | 2 +- py/utils.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/py/download.py b/py/download.py index 87e0e45..31a2a35 100644 --- a/py/download.py +++ b/py/download.py @@ -265,7 +265,7 @@ async def download_model_file( # Write description file description = task_content.description description_file = utils.join_path(download_path, f"{task_id}.md") - with open(description_file, "w") as f: + with open(description_file, "w", encoding="utf-8", newline="") as f: f.write(description) model_path = utils.get_full_path(model_type, path_index, fullname) diff --git a/py/services.py b/py/services.py index dde82ba..9518a3f 100644 --- a/py/services.py +++ b/py/services.py @@ -90,7 +90,7 @@ def get_model_info(model_path: str): description_file = utils.join_path(directory, description_file) description = None if os.path.isfile(description_file): - with open(description_file, "r", encoding="utf-8") as f: + with open(description_file, "r", encoding="utf-8", newline="") as f: description = f.read() return { diff --git a/py/utils.py b/py/utils.py index 18099c8..1aa9dff 100644 --- a/py/utils.py +++ b/py/utils.py @@ -44,7 +44,7 @@ def download_web_distribution(version: str): web_version = "0.0.0" version_file = join_path(web_path, "version.yaml") if os.path.exists(version_file): - with open(version_file, "r") as f: + with open(version_file, "r", encoding="utf-8", newline="") as f: version_content = yaml.safe_load(f) web_version = version_content.get("version", web_version) @@ -262,7 +262,7 @@ def save_model_description(model_path: str, content: Any): extension = ".md" new_desc_path = join_path(base_dirname, f"{basename}{extension}") - with open(new_desc_path, "w", encoding="utf-8") as f: + with open(new_desc_path, "w", encoding="utf-8", newline="") as f: f.write(content)