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.
This commit is contained in:
parent
41c13438b4
commit
ceb1b6450e
3 changed files with 7 additions and 4 deletions
Binary file not shown.
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue