diff options
-rw-r--r-- | host/utils/uhd_images_downloader.py.in | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/host/utils/uhd_images_downloader.py.in b/host/utils/uhd_images_downloader.py.in index 4c39aece2..b08a1df99 100644 --- a/host/utils/uhd_images_downloader.py.in +++ b/host/utils/uhd_images_downloader.py.in @@ -55,7 +55,7 @@ def log(level, message): def parse_args(): """Setup argument parser and parse""" parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) - parser.add_argument('-t', '--types', type=str, default="", + parser.add_argument('-t', '--types', action='append', help="RegEx to select image sets from the manifest file.") parser.add_argument('-i', '--install-location', default=None, @@ -155,7 +155,7 @@ def write_inventory(inventory, inventory_fn): return False -def lookup_urls(regex, manifest, inventory, refetch=False): +def lookup_urls(regex_l, manifest, inventory, refetch=False): """Takes a list of RegExs to match within the manifest, returns a list of tuples with (hash, URL) that match the targets and are not in the inventory""" selected_targets = [] @@ -163,7 +163,7 @@ def lookup_urls(regex, manifest, inventory, refetch=False): # Iterate through the possible targets in the manifest. # If any of them match any of the RegExs supplied, add the URL to the # return list - if re.findall(regex, target): + if all(map((lambda regex: re.findall(regex, target)), regex_l)): log("TRACE", "Selected target: {}".format(target)) target_info = manifest.get(target) target_url = target_info.get("url") @@ -328,10 +328,13 @@ def main(): )) # Determine the URLs to download based on the input regular expressions - types_regex = _DEFAULT_TARGET_REGEX if args.types == "" else args.types + if not args.types: + types_regex_l = [_DEFAULT_TARGET_REGEX] + else: + types_regex_l = args.types - log("TRACE", "RegEx for target selection: {}".format(types_regex)) - targets_info = lookup_urls(types_regex, manifest, inventory, args.refetch) + log("TRACE", "RegExs for target selection: {}".format(types_regex_l)) + targets_info = lookup_urls(types_regex_l, manifest, inventory, args.refetch) # Exit early if we don't have anything to download if targets_info: target_urls = [info.get("url") for info in targets_info] |