Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions _tests/test_createJson.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@


def getAddonManifest():
with open(MANIFEST_FILE) as f:
with open(MANIFEST_FILE, encoding="utf-8") as f:
manifest = addonManifest.AddonManifest(f)
return manifest

Expand Down Expand Up @@ -74,10 +74,10 @@ def test_contentsMatchesExampleFile(self):
def _assertJsonFilesEqual(self, actualJsonPath: str, expectedJsonPath: str):

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

Expand Down
4 changes: 2 additions & 2 deletions _tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@


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


def getAddonManifest():
with open(MANIFEST_FILE) as f:
with open(MANIFEST_FILE, encoding="utf-8") as f:
manifest = addonManifest.AddonManifest(f)
return manifest

Expand Down
2 changes: 1 addition & 1 deletion _validate/createJson.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def generateJsonFile(

filePath = buildOutputFilePath(data, parentDir)

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

Expand Down
4 changes: 2 additions & 2 deletions _validate/regenerateTranslations.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


def regenerateJsonFile(filePath: str, errorFilePath: Optional[str]) -> None:
with open(filePath) as f:
with open(filePath, encoding="utf-8") as f:
addonData = json.load(f)
if addonData.get("legacy"):
return
Expand All @@ -44,7 +44,7 @@ def regenerateJsonFile(filePath: str, errorFilePath: Optional[str]) -> None:
}
)

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

Expand Down
8 changes: 4 additions & 4 deletions _validate/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def getAddonMetadata(filename: str) -> JsonObjT:
"""Loads addon submission metadata json file and returns as object.
Raises if the metadata does not conform to the schema.
"""
with open(filename) as f:
with open(filename, encoding="utf-8") as f:
data: JsonObjT = json.load(f)
_validateJson(data)
return data
Expand All @@ -51,15 +51,15 @@ def getAddonMetadata(filename: str) -> JsonObjT:
def getExistingVersions(verFilename: str) -> List[str]:
"""Loads API versions file and returns list of versions formatted as strings.
"""
with open(verFilename) as f:
with open(verFilename, encoding="utf-8") as f:
data: List[JsonObjT] = json.load(f)
return [_formatVersionString(version["apiVer"].values()) for version in data]


def getExistingStableVersions(verFilename: str) -> List[str]:
"""Loads API versions file and returns list of stable versions formatted as strings.
"""
with open(verFilename) as f:
with open(verFilename, encoding="utf-8") as f:
data: List[JsonObjT] = json.load(f)
return [
_formatVersionString(version["apiVer"].values())
Expand All @@ -72,7 +72,7 @@ def _validateJson(data: JsonObjT) -> None:
""" Ensure that the loaded metadata conforms to the schema.
Raise error if not
"""
with open(JSON_SCHEMA) as f:
with open(JSON_SCHEMA, encoding="utf-8") as f:
schema = json.load(f)
try:
validate(instance=data, schema=schema)
Expand Down
Loading