Skip to content

Commit 354918f

Browse files
authored
Use utf-8 for validation (#40)
1 parent 888b38f commit 354918f

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

_tests/test_createJson.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333

3434
def getAddonManifest():
35-
with open(MANIFEST_FILE) as f:
35+
with open(MANIFEST_FILE, encoding="utf-8") as f:
3636
manifest = addonManifest.AddonManifest(f)
3737
return manifest
3838

@@ -74,10 +74,10 @@ def test_contentsMatchesExampleFile(self):
7474
def _assertJsonFilesEqual(self, actualJsonPath: str, expectedJsonPath: str):
7575

7676
# Not equal, how are they different?
77-
with open(VALID_JSON) as expectedFile:
77+
with open(VALID_JSON, encoding="utf-8") as expectedFile:
7878
expectedJson = json.load(expectedFile)
7979
del expectedJson["sha256-comment"] # remove explanatory comment
80-
with open(actualJsonPath) as actualFile:
80+
with open(actualJsonPath, encoding="utf-8") as actualFile:
8181
actualJson = json.load(actualFile)
8282
del actualJson["submissionTime"] # remove submission time
8383

_tests/test_validate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626

2727

2828
def getValidAddonSubmission() -> validate.JsonObjT:
29-
with open(VALID_SUBMISSION_JSON_FILE) as f:
29+
with open(VALID_SUBMISSION_JSON_FILE, encoding="utf-8") as f:
3030
submission = json.load(f)
3131
return submission
3232

3333

3434
def getAddonManifest():
35-
with open(MANIFEST_FILE) as f:
35+
with open(MANIFEST_FILE, encoding="utf-8") as f:
3636
manifest = addonManifest.AddonManifest(f)
3737
return manifest
3838

_validate/createJson.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def generateJsonFile(
6161

6262
filePath = buildOutputFilePath(data, parentDir)
6363

64-
with open(filePath, "wt") as f:
64+
with open(filePath, "wt", encoding="utf-8") as f:
6565
json.dump(data, f, indent="\t")
6666
print(f"Wrote json file: {filePath}")
6767

_validate/regenerateTranslations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323

2424
def regenerateJsonFile(filePath: str, errorFilePath: Optional[str]) -> None:
25-
with open(filePath) as f:
25+
with open(filePath, encoding="utf-8") as f:
2626
addonData = json.load(f)
2727
if addonData.get("legacy"):
2828
return
@@ -44,7 +44,7 @@ def regenerateJsonFile(filePath: str, errorFilePath: Optional[str]) -> None:
4444
}
4545
)
4646

47-
with open(filePath, "wt") as f:
47+
with open(filePath, "wt", encoding="utf-8") as f:
4848
json.dump(addonData, f, indent="\t")
4949
print(f"Wrote json file: {filePath}")
5050

_validate/validate.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def getAddonMetadata(filename: str) -> JsonObjT:
4242
"""Loads addon submission metadata json file and returns as object.
4343
Raises if the metadata does not conform to the schema.
4444
"""
45-
with open(filename) as f:
45+
with open(filename, encoding="utf-8") as f:
4646
data: JsonObjT = json.load(f)
4747
_validateJson(data)
4848
return data
@@ -51,15 +51,15 @@ def getAddonMetadata(filename: str) -> JsonObjT:
5151
def getExistingVersions(verFilename: str) -> List[str]:
5252
"""Loads API versions file and returns list of versions formatted as strings.
5353
"""
54-
with open(verFilename) as f:
54+
with open(verFilename, encoding="utf-8") as f:
5555
data: List[JsonObjT] = json.load(f)
5656
return [_formatVersionString(version["apiVer"].values()) for version in data]
5757

5858

5959
def getExistingStableVersions(verFilename: str) -> List[str]:
6060
"""Loads API versions file and returns list of stable versions formatted as strings.
6161
"""
62-
with open(verFilename) as f:
62+
with open(verFilename, encoding="utf-8") as f:
6363
data: List[JsonObjT] = json.load(f)
6464
return [
6565
_formatVersionString(version["apiVer"].values())
@@ -72,7 +72,7 @@ def _validateJson(data: JsonObjT) -> None:
7272
""" Ensure that the loaded metadata conforms to the schema.
7373
Raise error if not
7474
"""
75-
with open(JSON_SCHEMA) as f:
75+
with open(JSON_SCHEMA, encoding="utf-8") as f:
7676
schema = json.load(f)
7777
try:
7878
validate(instance=data, schema=schema)

0 commit comments

Comments
 (0)