mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Fix file encoding for some loads.
We've actually been pretty good at getting this right in most of the code base, but we've missed it in a few places. Python defaults to the encoding of the current locale unless otherwise specified, and for a US English Windows install that's cp1252, not UTF-8. I'm not brave enough to change the locale at startup because I don't know how that might affect CJK encoding users (or for that matter, non-Latin derived alphabet UTF-8 variants). Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2786.
This commit is contained in:
parent
fa070b2126
commit
99ea06c0d5
@ -17,6 +17,7 @@ Saves from 6.x are not compatible with 7.0.
|
|||||||
|
|
||||||
* **[Campaign]** Fixed a longstanding bug where oversized airlifts could corrupt a save with empty convoys.
|
* **[Campaign]** Fixed a longstanding bug where oversized airlifts could corrupt a save with empty convoys.
|
||||||
* **[Modding]** Fixed an issue where Falklands campaigns created or edited with new versions of DCS could not be loaded.
|
* **[Modding]** Fixed an issue where Falklands campaigns created or edited with new versions of DCS could not be loaded.
|
||||||
|
* **[Modding]** Fixed decoding of campaign yaml files to use UTF-8 rather than the system locale's default. It's now possible to use "Bf 109 K-4 Kurfürst" as a preferred aircraft type.
|
||||||
|
|
||||||
# 6.1.1
|
# 6.1.1
|
||||||
|
|
||||||
|
|||||||
@ -57,7 +57,7 @@ class Campaign:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_file(cls, path: Path) -> Campaign:
|
def from_file(cls, path: Path) -> Campaign:
|
||||||
with path.open() as campaign_file:
|
with path.open(encoding="utf-8") as campaign_file:
|
||||||
data = yaml.safe_load(campaign_file)
|
data = yaml.safe_load(campaign_file)
|
||||||
|
|
||||||
sanitized_theater = data["theater"].replace(" ", "")
|
sanitized_theater = data["theater"].replace(" ", "")
|
||||||
|
|||||||
@ -16,7 +16,7 @@ def init_logging(version: str) -> None:
|
|||||||
log_config = resources / "default_logging.yaml"
|
log_config = resources / "default_logging.yaml"
|
||||||
if (custom_log_config := resources / "logging.yaml").exists():
|
if (custom_log_config := resources / "logging.yaml").exists():
|
||||||
log_config = custom_log_config
|
log_config = custom_log_config
|
||||||
with log_config.open() as log_file:
|
with log_config.open(encoding="utf-8") as log_file:
|
||||||
logging.config.dictConfig(yaml.safe_load(log_file))
|
logging.config.dictConfig(yaml.safe_load(log_file))
|
||||||
|
|
||||||
logging.info(f"DCS Liberation {version}")
|
logging.info(f"DCS Liberation {version}")
|
||||||
|
|||||||
@ -92,13 +92,13 @@ class TheaterLoader:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def menu_thumbnail_dcs_relative_path(self) -> Path:
|
def menu_thumbnail_dcs_relative_path(self) -> Path:
|
||||||
with self.descriptor_path.open() as descriptor_file:
|
with self.descriptor_path.open(encoding="utf-8") as descriptor_file:
|
||||||
data = yaml.safe_load(descriptor_file)
|
data = yaml.safe_load(descriptor_file)
|
||||||
name = data.get("pydcs_name", data["name"])
|
name = data.get("pydcs_name", data["name"])
|
||||||
return Path("Mods/terrains") / name / "Theme/icon.png"
|
return Path("Mods/terrains") / name / "Theme/icon.png"
|
||||||
|
|
||||||
def load(self) -> ConflictTheater:
|
def load(self) -> ConflictTheater:
|
||||||
with self.descriptor_path.open() as descriptor_file:
|
with self.descriptor_path.open(encoding="utf-8") as descriptor_file:
|
||||||
data = yaml.safe_load(descriptor_file)
|
data = yaml.safe_load(descriptor_file)
|
||||||
return ConflictTheater(
|
return ConflictTheater(
|
||||||
TERRAINS_BY_NAME[data.get("pydcs_name", data["name"])],
|
TERRAINS_BY_NAME[data.get("pydcs_name", data["name"])],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user