Skip to content

Commit

Permalink
Ensure json files are read and writen in utf-8 (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
nvdaes authored Sep 23, 2024
1 parent dc1034b commit 794090b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/transform/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def writeAddons(addonDir: str, addons: WriteableAddons, supportedLanguages: Set[
for addonName in addons[nvdaAPIVersion][channel]:
addon = addons[nvdaAPIVersion][channel][addonName]
addonWritePath = f"{addonDir}/en/{str(nvdaAPIVersion)}/{addonName}"
with open(addon.pathToData, "r") as oldAddonFile:
with open(addon.pathToData, "r", encoding="utf-8") as oldAddonFile:
addonData: Dict = json.load(oldAddonFile)
if "translations" in addonData:
del addonData["translations"]
Expand Down Expand Up @@ -163,7 +163,7 @@ def readAddons(addonDir: str) -> Iterable[Addon]:
Skips addons and logs errors if the naming schema or json schema do not match what is expected.
"""
for fileName in glob.glob(f"{addonDir}/**/*.json"):
with open(fileName, "r") as addonFile:
with open(fileName, "r", encoding="utf-8") as addonFile:
addonData = json.load(addonFile)
try:
validateJson(addonData, JSONSchemaPaths.ADDON_DATA)
Expand Down

0 comments on commit 794090b

Please sign in to comment.