mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Use utf-8 for report
This commit is contained in:
parent
d2e6d91880
commit
aa74604d29
@ -503,7 +503,7 @@ class OutputDirectory:
|
|||||||
try:
|
try:
|
||||||
self._prev_report = Report.load(self._report_path)
|
self._prev_report = Report.load(self._report_path)
|
||||||
log.explain("Loaded report successfully")
|
log.explain("Loaded report successfully")
|
||||||
except (OSError, json.JSONDecodeError, ReportLoadError) as e:
|
except (OSError, UnicodeDecodeError, json.JSONDecodeError, ReportLoadError) as e:
|
||||||
log.explain("Failed to load report")
|
log.explain("Failed to load report")
|
||||||
log.explain(str(e))
|
log.explain(str(e))
|
||||||
|
|
||||||
|
@ -100,10 +100,10 @@ class Report:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def load(cls, path: Path) -> "Report":
|
def load(cls, path: Path) -> "Report":
|
||||||
"""
|
"""
|
||||||
May raise OSError, JsonDecodeError, ReportLoadError.
|
May raise OSError, UnicodeDecodeError, JsonDecodeError, ReportLoadError.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
with open(path) as f:
|
with open(path, encoding="utf-8") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
|
||||||
if not isinstance(data, dict):
|
if not isinstance(data, dict):
|
||||||
@ -148,7 +148,7 @@ class Report:
|
|||||||
"encountered_errors": self.encountered_errors,
|
"encountered_errors": self.encountered_errors,
|
||||||
}
|
}
|
||||||
|
|
||||||
with open(path, "w") as f:
|
with open(path, "w", encoding="utf-8") as f:
|
||||||
json.dump(data, f, indent=2, sort_keys=True)
|
json.dump(data, f, indent=2, sort_keys=True)
|
||||||
f.write("\n") # json.dump doesn't do this
|
f.write("\n") # json.dump doesn't do this
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user