From e5a3d9074062a37a5d425d0b3b7611e96e3e3ade Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Fri, 4 Mar 2022 16:29:38 +0100 Subject: [BUILD] Improve docker images download script testability Command line argument parsing routine now returns raw ArgumentParser object for easier instantiation in test routines. Change-Id: Icac599a6e72b0a7514a1a33d23624c44dc819b9b Issue-ID: INT-1429 Signed-off-by: Bartek Grzybowski --- build/download/download.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/build/download/download.py b/build/download/download.py index 94cc1b54..d47462cf 100755 --- a/build/download/download.py +++ b/build/download/download.py @@ -78,14 +78,7 @@ def parse_args(): help='Check what is missing. No download.') parser.add_argument('--debug', action='store_true', default=False, help='Turn on debug output') - - args = parser.parse_args() - - for arg in ('docker', 'npm', 'http', 'rpm', 'git', 'pypi'): - if getattr(args, arg): - return args - - parser.error('One of --docker, --npm, --http, --rpm, --git or --pypi must be specified') + return parser def log_start(item_type): @@ -156,7 +149,15 @@ def run_cli(): if sys.version_info.major < 3: log.error('Unfortunately Python 2 is not supported for data download.') sys.exit(1) - args = parse_args() + + parser = parse_args() + args = parser.parse_args() + + for arg in ('docker', 'npm', 'http', 'rpm', 'git', 'pypi'): + if getattr(args, arg): + break + else: + parser.error('One of --docker, --npm, --http, --rpm, --git or --pypi must be specified') console_handler = logging.StreamHandler(sys.stdout) console_formatter = logging.Formatter('%(message)s') -- cgit 1.2.3-korg