Skip to content
Snippets Groups Projects
Verified Commit b9d3ac61 authored by Antoine Lambert's avatar Antoine Lambert
Browse files

gnu: Fix KeyError exception due to missing field in JSON data

Latest GNU JSON listing is missing the contents field for a directory
so a KeyError exception was raised by the lister.
parent f2f9c7d1
No related branches found
Tags v0.0.4
No related merge requests found
Pipeline #13717 passed
No preview for this file type
......@@ -69,5 +69,6 @@
{"type":"file","name":"xboard-4.2.5.tar.gz","size":1055502,"time":"1008466945"},
{"type":"file","name":"xboard-4.2.6.tar.gz","size":1057625,"time":"1012641715"},
{"type":"file","name":"xboard-4.2.7.tar.gz","size":1318110,"time":"1070057764"}
]}
]},
{"type":"directory","name":"no-contents","size":4096,"time":"1254860068"}
]
......@@ -61,7 +61,7 @@ class GNUTree:
for directory in raw_data["contents"]:
if directory["name"] not in self.top_level_directories:
continue
infos = directory["contents"]
infos = directory.get("contents", [])
for info in infos:
if info["type"] == "directory":
package_url = "%s/%s/%s/" % (
......@@ -69,7 +69,9 @@ class GNUTree:
directory["name"],
info["name"],
)
package_artifacts = find_artifacts(info["contents"], package_url)
package_artifacts = find_artifacts(
info.get("contents", []), package_url
)
if package_artifacts != []:
repo_details = {
"name": info["name"],
......@@ -146,7 +148,7 @@ def find_artifacts(
# It will recursively check for artifacts in all sub-folders
elif filetype == "directory":
tarballs_in_dir = find_artifacts(
info_file["contents"], url + filename + "/"
info_file.get("contents", []), url + filename + "/"
)
artifacts.extend(tarballs_in_dir)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment