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
7 changes: 2 additions & 5 deletions _validate/addonManifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ class AddonManifest(ConfigObj):
# Long description with further information and instructions
description = string(default=None)

# Document changes between the previous and the current versions.
changelog = string(default=None)

# Name of the author or entity that created the add-on
author = string()

Expand Down Expand Up @@ -92,8 +89,8 @@ def __init__(self, input: str | TextIOBase, translatedInput: str | None = None):
self._translatedConfig = None
if translatedInput is not None:
self._translatedConfig = ConfigObj(translatedInput, encoding="utf-8", default_encoding="utf-8")
for key in ("summary", "description", "changelog"):
val: str | None = self._translatedConfig.get(key) # type: ignore[reportUnknownMemberType]
for key in ("summary", "description"):
val: str = self._translatedConfig.get(key) # type: ignore[reportUnknownMemberType]
if val:
self[key] = val

Expand Down
29 changes: 3 additions & 26 deletions _validate/addonVersion_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@
"sourceURL": "https://github.com/nvaccess/addon-datastore/",
"license": "GPL v2",
"licenseURL": "https://github.com/nvaccess/addon-datastore/license.MD",
"changelog": "New features",
"translations": [
{
"language": "de",
"displayName": "Mein Addon",
"description": "erleichtert das Durchführen von xyz",
"changelog": "Neue Funktionen"
"description": "erleichtert das Durchführen von xyz"
}
],
"reviewUrl": "https://github.com/nvaccess/addon-datastore/discussions/1942#discussioncomment-7453248",
Expand Down Expand Up @@ -230,16 +228,6 @@
"title": "The URL of the license",
"type": "string"
},
"changelog": {
"$id": "#/properties/changelog",
"default": "",
"description": "Changes between the previous and the current version",
"examples": [
"New feature"
],
"title": "Add-on changelog (en)",
"type": "string"
},
"legacy": {
"$id": "#/properties/legacy",
"default": false,
Expand All @@ -259,8 +247,7 @@
{
"language": "de",
"displayName": "Mein Addon",
"description": "erleichtert das Durchführen von xyz",
"changelog": "Neue Funktionen"
"description": "erleichtert das Durchführen von xyz"
}
]
],
Expand Down Expand Up @@ -370,8 +357,7 @@
{
"language": "de",
"displayName": "Mein Addon",
"description": "erleichtert das Durchführen von xyz",
"changelog": "Neue Funktionen"
"description": "erleichtert das Durchführen von xyz"
}
],
"required": [
Expand Down Expand Up @@ -407,15 +393,6 @@
],
"title": "The translated description",
"type": "string"
},
"changelog": {
"default": "",
"description": "Translated description of changes between the previous and this add-on version",
"examples": [
"Neue Funktionen"
],
"title": "The translated changelog",
"type": "string"
}
}
}
Expand Down
24 changes: 4 additions & 20 deletions _validate/createJson.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ class AddonData:
sourceURL: str
license: str
homepage: str | None
changelog: str | None
licenseURL: str | None
submissionTime: int
translations: list[dict[str, str | None]]
translations: list[dict[str, str]]


def getSha256(addonPath: str) -> str:
Expand Down Expand Up @@ -109,31 +108,17 @@ def _createDataclassMatchingJsonSchema(

# Add optional fields
homepage: str | None = manifest.get("url") # type: ignore[reportUnknownMemberType]
if homepage == "None":
# The config default is None
# which is parsed by configobj as a string not a NoneType
if not homepage or homepage == "None":
homepage = None
changelog: str | None = manifest.get("changelog") # type: ignore[reportUnknownMemberType]
if changelog == "None":
# The config default is None
# which is parsed by configobj as a string not a NoneType
changelog = None
translations: list[dict[str, str | None]] = []
for langCode, translatedManifest in getAddonManifestLocalizations(manifest):
# Add optional translated changelog.
translatedChangelog: str | None = translatedManifest.get("changelog") # type: ignore[reportUnknownMemberType]
if translatedChangelog == "None":
# The config default is None
# which is parsed by configobj as a string not a NoneType
translatedChangelog = None

translations: list[dict[str, str]] = []
for langCode, translatedManifest in getAddonManifestLocalizations(manifest):
try:
translations.append(
{
"language": langCode,
"displayName": cast(str, translatedManifest["summary"]),
"description": cast(str, translatedManifest["description"]),
"changelog": translatedChangelog,
},
)
except KeyError as e:
Expand All @@ -156,7 +141,6 @@ def _createDataclassMatchingJsonSchema(
sourceURL=sourceUrl,
license=licenseName,
homepage=homepage,
changelog=changelog,
licenseURL=licenseUrl,
submissionTime=getCurrentTime(),
translations=translations,
Expand Down
12 changes: 1 addition & 11 deletions _validate/regenerateTranslations.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,13 @@ def regenerateJsonFile(filePath: str, errorFilePath: str | None) -> None:
with open(errorFilePath, "w") as errorFile:
errorFile.write(f"Validation Errors:\n{manifest.errors}")
return
changelog = manifest.get("changelog") # type: ignore[reportUnknownMemberType]
if changelog == "None":
# The config default is None
# which is parsed by configobj as a string not a NoneType
changelog = None

for langCode, manifest in getAddonManifestLocalizations(manifest):
translatedChangelog = manifest.get("changelog") # type: ignore[reportUnknownMemberType]
if translatedChangelog == "None":
# The config default is None
# which is parsed by configobj as a string not a NoneType
translatedChangelog = None
addonData["translations"].append(
{
"language": langCode,
"displayName": manifest["summary"],
"description": manifest["description"],
"changelog": translatedChangelog,
},
)

Expand Down
14 changes: 0 additions & 14 deletions _validate/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,6 @@ def checkDescriptionMatches(manifest: AddonManifest, submission: JsonObjT) -> Va
)


def checkChangelogMatches(manifest: AddonManifest, submission: JsonObjT) -> ValidationErrorGenerator:
"""The submission changelog must match the *.nvda-addon manifest changelog field."""
changelog = manifest.get("changelog") # type: ignore[reportUnknownMemberType]
if changelog == "None":
# The config default is None which is parsed by configobj as a string not a NoneType
changelog = None
if changelog != submission.get("changelog"):
yield (
f"Submission 'changelog' must be set to '{manifest.get('changelog')}' " # type: ignore[reportUnknownMemberType]
f"in json file instead of {submission.get('changelog')}"
)


def checkUrlMatchesHomepage(manifest: AddonManifest, submission: JsonObjT) -> ValidationErrorGenerator:
"""The submission homepage must match the *.nvda-addon manifest url field."""
manifestUrl = manifest.get("url") # type: ignore[reportUnknownMemberType]
Expand Down Expand Up @@ -345,7 +332,6 @@ def validateSubmission(submissionFilePath: str, verFilename: str) -> ValidationE
manifest = getAddonManifest(addonDestPath)
yield from checkSummaryMatchesDisplayName(manifest, submissionData)
yield from checkDescriptionMatches(manifest, submissionData)
yield from checkChangelogMatches(manifest, submissionData)
yield from checkUrlMatchesHomepage(manifest, submissionData)
yield from checkAddonId(manifest, submissionFilePath, submissionData)
yield from checkMinNVDAVersionMatches(manifest, submissionData)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ reportMissingTypeStubs = false

[tool.uv]
default-groups = "all"
python-preference = "only-system"
environments = ["sys_platform == 'win32'"]
required-version = ">=0.8"

Expand Down
3 changes: 1 addition & 2 deletions tests/testData/addons/fake/13.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
},
"displayName": "mock addon",
"description": "The description for the addon",
"changelog": "Changes for this add-on version",
"homepage": "https://nvaccess.org",
"publisher": "Name of addon author or organisation",
"minNVDAVersion": {
Expand All @@ -24,7 +23,7 @@
"channel": "stable",
"URL": "https://github.com/nvaccess/dont/use/this/address/fake.nvda-addon",
"sha256-comment": "SHA for the fake.nvda-addon file",
"sha256": "50a8011a807665bcb8fdd177c276fef3b3f7f754796c5990ebe14e80c28b14ef",
"sha256": "e27fa778cb99f83ececeb0bc089033929eab5a2fa475ce63e68f50b03b6ab585",
"sourceURL": "https://github.com/nvaccess/dont/use/this/address",
"license": "GPL v2",
"licenseURL": "https://www.gnu.org/licenses/gpl-2.0.html",
Expand Down
Binary file modified tests/testData/fake.nvda-addon
Binary file not shown.
1 change: 0 additions & 1 deletion tests/testData/manifest.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name = fake
summary = "mock addon"
description = """The description for the addon"""
changelog = """Changes for this add-on version"""
author = "Name of addon author or organisation"
url = https://nvaccess.org
version = 13.0
Expand Down
1 change: 0 additions & 1 deletion tests/test_createJson.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def test_validVersion(self):
sourceURL="https://example.com",
license="GPL v2",
homepage="https://example.com",
changelog="""Changes for this add-on version""",
licenseURL="https://www.gnu.org/licenses/gpl-2.0.html",
submissionTime=createJson.getCurrentTime(),
translations=[],
Expand Down
28 changes: 1 addition & 27 deletions tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_missingHTTPsAndExt(self):
class Validate_checkSha256(unittest.TestCase):
"""Tests for the checkSha256 function"""

validSha = "50a8011a807665bcb8fdd177c276fef3b3f7f754796c5990ebe14e80c28b14ef"
validSha = "e27fa778cb99f83ececeb0bc089033929eab5a2fa475ce63e68f50b03b6ab585"

def test_valid(self):
errors = validate.checkSha256(ADDON_PACKAGE, expectedSha=self.validSha.upper())
Expand Down Expand Up @@ -152,32 +152,6 @@ def test_invalid(self):
)


class Validate_checkChangelogMatches(unittest.TestCase):
def setUp(self):
self.submissionData = getValidAddonSubmission()
self.manifest = getAddonManifest()

def test_valid(self):
errors = list(
validate.checkChangelogMatches(self.manifest, self.submissionData),
)
self.assertEqual(errors, [])

def test_invalid(self):
badChangelog = "bad changelog"
self.submissionData["changelog"] = badChangelog
errors = list(
validate.checkChangelogMatches(self.manifest, self.submissionData),
)
self.assertEqual(
errors,
[
f"Submission 'changelog' must be set to '{self.manifest['changelog']}' in json file"
f" instead of {badChangelog}",
],
)


class Validate_checkAddonId(unittest.TestCase):
"""
Manifest 'name' considered source of truth for addonID
Expand Down
Loading