python: Update the gem5 lib downloader 'is_zipped' checker
Previously, gem5 resources' resources.json file set the 'is_zipped' field to a string, either "True" or "False". As JSON supports booleans, this was updated in an upcoming patch to use boolean values instead: https://gem5-review.googlesource.com/c/public/gem5-resources/+/51168. This patch updates the gem5 library downloader to use the new true/false values but remains backwards compataible with the old string-based way of declaring the value of this field. Change-Id: I804ce66e8ca1989955b09041b7d1c894de74dac0 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51329 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -251,7 +251,24 @@ def get_resource(
|
||||
)
|
||||
|
||||
download_dest = to_path
|
||||
run_unzip = unzip and resource_json["is_zipped"].lower() == "true"
|
||||
|
||||
# This if-statement is remain backwards compatable with the older,
|
||||
# string-based way of doing things. It can be refactored away over
|
||||
# time:
|
||||
# https://gem5-review.googlesource.com/c/public/gem5-resources/+/51168
|
||||
if isinstance(resource_json["is_zipped"], str):
|
||||
run_unzip = unzip and resource_json["is_zipped"].lower() == "true"
|
||||
elif isinstance(resource_json["is_zipped"], bool):
|
||||
run_unzip = unzip and resource_json["is_zipped"]
|
||||
else:
|
||||
raise Exception(
|
||||
"The resource.json entry for '{}' has a value for the "
|
||||
"'is_zipped' field which is neither a string or a boolean."
|
||||
.format(
|
||||
resource_name
|
||||
)
|
||||
)
|
||||
|
||||
if run_unzip:
|
||||
download_dest += ".gz"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user