Skip to content

Commit 54ba922

Browse files
committed
Fixup translation generation: reset temp files
1 parent 8cda1b2 commit 54ba922

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

_validate/manifestLoader.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from glob import glob
66
import os
77
import pathlib
8+
import shutil
89
from typing import Generator, Tuple
910
import zipfile
1011
from addonManifest import AddonManifest
@@ -16,11 +17,14 @@ def getAddonManifest(addonPath: str) -> AddonManifest:
1617
""" Extract manifest.ini from *.nvda-addon and parse.
1718
Raise on error.
1819
"""
19-
expandedPath = os.path.join(TEMP_DIR, "nvda-addon")
20+
extractDir = os.path.join(TEMP_DIR, "tempAddon")
21+
if pathlib.Path(extractDir).exists():
22+
shutil.rmtree(extractDir)
23+
pathlib.Path(extractDir).mkdir()
2024
with zipfile.ZipFile(addonPath, "r") as z:
2125
for info in z.infolist():
22-
z.extract(info, expandedPath)
23-
filePath = os.path.join(expandedPath, "manifest.ini")
26+
z.extract(info, extractDir)
27+
filePath = os.path.join(extractDir, "manifest.ini")
2428
try:
2529
manifest = AddonManifest(filePath)
2630
return manifest

_validate/regenerateTranslations.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
sys.path.append(os.path.dirname(__file__)) # To allow this module to be run as a script by runcreatejson.bat
1919
# E402 module level import not at top of file
20-
from manifestLoader import getAddonManifest, getAddonManifestLocalizations, TEMP_DIR # noqa:E402
20+
from manifestLoader import getAddonManifest, getAddonManifestLocalizations # noqa:E402
2121
del sys.path[-1]
2222

2323

@@ -27,8 +27,7 @@ def regenerateJsonFile(filePath: str, errorFilePath: Optional[str]) -> None:
2727
if addonData.get("legacy"):
2828
return
2929
addonData["translations"] = []
30-
addonFilePath = os.path.join(TEMP_DIR, "addon.nvda-addon")
31-
urlretrieve(addonData["URL"], addonFilePath)
30+
addonFilePath, _ = urlretrieve(addonData["URL"])
3231
manifest = getAddonManifest(addonFilePath)
3332
if manifest.errors:
3433
if errorFilePath:

_validate/validate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ def validateSubmission(submissionFilePath: str, verFilename: str) -> ValidationE
315315
raise ValueError(submissionData["URL"])
316316

317317
addonDestPath = os.path.join(TEMP_DIR, "addon.nvda-addon")
318+
os.remove(addonDestPath)
318319
yield from downloadAddon(url=submissionData["URL"], destPath=addonDestPath)
319320

320321
checksumErrors = list(checkSha256(addonDestPath, expectedSha=submissionData["sha256"]))

0 commit comments

Comments
 (0)