Skip to content

Commit

Permalink
SConstruct: remove add-on store json generator as the store wil gener…
Browse files Browse the repository at this point in the history
…ate it when add-ons are submitted
  • Loading branch information
josephsl committed May 7, 2024
1 parent f0fff5d commit 2354f5e
Showing 1 changed file with 1 addition and 78 deletions.
79 changes: 1 addition & 78 deletions sconstruct
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def mdTool(env):

def validateVersionNumber(key, val, env):
# Used to make sure version major.minor.patch are integers to comply with NV Access add-on store.
# Ignore all this if version number is not specified, in which case json generator will validate this info.
# Ignore all this if version number is not specified.
if val == "0.0.0":
return
versionNumber = val.split(".")
Expand Down Expand Up @@ -170,86 +170,9 @@ def createAddonBundleFromPath(path, dest):
absPath = os.path.join(dir, filename)
if pathInBundle not in buildVars.excludedFiles:
z.write(absPath, pathInBundle)
# Add-on store does not require submitting json files.
# createAddonStoreJson(dest)
return dest


def createAddonStoreJson(bundle):
"""Creates add-on store JSON file from an add-on package and manifest data."""
import json
import hashlib
# Set different json file names and version number properties based on version number parsing results.
if env["versionNumber"] == "0.0.0":
env["versionNumber"] = buildVars.addon_info["addon_version"]
versionNumberParsed = env["versionNumber"].split(".")
if all([part.isnumeric() for part in versionNumberParsed]):
if len(versionNumberParsed) == 1:
versionNumberParsed += ["0", "0"]
elif len(versionNumberParsed) == 2:
versionNumberParsed.append("0")
else:
versionNumberParsed = []
if len(versionNumberParsed):
major, minor, patch = [int(part) for part in versionNumberParsed]
jsonFilename = f'{major}.{minor}.{patch}.json'
else:
jsonFilename = f'{buildVars.addon_info["addon_version"]}.json'
major, minor, patch = 0, 0, 0
print('Generating % s' % jsonFilename)
sha256 = hashlib.sha256()
with open(bundle, "rb") as f:
for byte_block in iter(lambda: f.read(65536), b""):
sha256.update(byte_block)
hashValue = sha256.hexdigest()
try:
minimumNVDAVersion = buildVars.addon_info["addon_minimumNVDAVersion"].split(".")
except AttributeError:
minimumNVDAVersion = [0, 0, 0]
minMajor, minMinor = minimumNVDAVersion[:2]
minPatch = minimumNVDAVersion[-1] if len(minimumNVDAVersion) == 3 else "0"
try:
lastTestedNVDAVersion = buildVars.addon_info["addon_lastTestedNVDAVersion"].split(".")
except AttributeError:
lastTestedNVDAVersion = [0, 0, 0]
lastTestedMajor, lastTestedMinor = lastTestedNVDAVersion[:2]
lastTestedPatch = lastTestedNVDAVersion[-1] if len(lastTestedNVDAVersion) == 3 else "0"
channel = buildVars.addon_info["addon_updateChannel"]
if channel is None:
channel = "stable"
addonStoreEntry = {
"addonId": buildVars.addon_info["addon_name"],
"displayName": buildVars.addon_info["addon_summary"],
"URL": "",
"description": buildVars.addon_info["addon_description"],
"sha256": hashValue,
"homepage": buildVars.addon_info["addon_url"],
"addonVersionName": buildVars.addon_info["addon_version"],
"addonVersionNumber": {
"major": major,
"minor": minor,
"patch": patch
},
"minNVDAVersion": {
"major": int(minMajor),
"minor": int(minMinor),
"patch": int(minPatch)
},
"lastTestedVersion": {
"major": int(lastTestedMajor),
"minor": int(lastTestedMinor),
"patch": int(lastTestedPatch)
},
"channel": channel,
"publisher": "",
"sourceURL": buildVars.addon_info["addon_sourceURL"],
"license": buildVars.addon_info["addon_license"],
"licenseURL": buildVars.addon_info["addon_licenseURL"],
}
with open(jsonFilename, "w") as addonStoreJson:
json.dump(addonStoreEntry, addonStoreJson, indent="\t")


def generateManifest(source, dest):
addon_info = buildVars.addon_info
with codecs.open(source, "r", "utf-8") as f:
Expand Down

0 comments on commit 2354f5e

Please sign in to comment.