Skip to content

Commit

Permalink
fix: read/write encoding for open(...) is now utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
tazlin committed Oct 23, 2023
1 parent cc246fb commit f88389f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion horde_worker_regen/bridge_data/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def save(self, file_path: str) -> None:
if self._yaml_loader is None:
self._yaml_loader = YAML()

with open(file_path, "w") as f:
with open(file_path, "w", encoding="utf-8") as f:
self._yaml_loader.dump(self.model_dump(), f)


Expand Down
4 changes: 2 additions & 2 deletions horde_worker_regen/bridge_data/load_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ def load(

if file_format == ConfigFormat.yaml:
yaml = YAML()
with open(file_path) as f:
with open(file_path, encoding="utf-8") as f:
config = yaml.load(f)

bridge_data = reGenBridgeData.model_validate(config)
if bridge_data is not None:
bridge_data._yaml_loader = yaml

if file_format == ConfigFormat.json:
with open(file_path) as f:
with open(file_path, encoding="utf-8") as f:
config = json.load(f)

bridge_data = reGenBridgeData.model_validate(config)
Expand Down
2 changes: 1 addition & 1 deletion load_env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def load_env_vars() -> None:
if not pathlib.Path("bridgeData.yaml").exists():
raise FileNotFoundError("bridgeData.yaml not found")

with open("bridgeData.yaml") as f:
with open("bridgeData.yaml", encoding="utf-8") as f:
config = yaml.load(f)

if "cache_home" in config:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bridge_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_bridge_data_yaml() -> None:

yaml = YAML(typ="safe")

with open(bridge_data_filename) as f:
with open(bridge_data_filename, encoding="utf-8") as f:
bridge_data_raw = yaml.load(f)

assert bridge_data_raw is not None
Expand Down

0 comments on commit f88389f

Please sign in to comment.