Skip to content

Commit

Permalink
πŸ› Fix private_django_api encoding on Windows (#795)
Browse files Browse the repository at this point in the history
fix private_django_api encoding
  • Loading branch information
Koncopd authored Jul 15, 2024
1 parent 353cb4c commit 0e0ae30
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lamindb_setup/core/_private_django_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down

0 comments on commit 0e0ae30

Please sign in to comment.