From 0e0ae30ec9ed2a86ff6867bc2c7aa15103af120a Mon Sep 17 00:00:00 2001 From: Sergei Rybakov Date: Mon, 15 Jul 2024 19:42:22 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20private=5Fdjango=5Fapi=20e?= =?UTF-8?q?ncoding=20on=20Windows=20(#795)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix private_django_api encoding --- lamindb_setup/core/_private_django_api.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lamindb_setup/core/_private_django_api.py b/lamindb_setup/core/_private_django_api.py index 3b9a2dda0..8269a9064 100644 --- a/lamindb_setup/core/_private_django_api.py +++ b/lamindb_setup/core/_private_django_api.py @@ -58,8 +58,10 @@ def private_django_api(reverse=False): django_path = Path(db.__file__).parent.parent + encoding = "utf8" if os.name == "nt" else None + def prune_file(file_path): - content = file_path.read_text() + content = file_path.read_text(encoding=encoding) original_content = content for attr in attributes: @@ -72,7 +74,7 @@ def prune_file(file_path): content = content.replace("Object_DoesNotExist", "ObjectDoesNotExist") if content != original_content: - file_path.write_text(content) + file_path.write_text(content, encoding=encoding) for file_path in django_path.rglob("*.py"): prune_file(file_path)