From 458eb240b82f9967e0188b2f760a3611aa6e9ab9 Mon Sep 17 00:00:00 2001 From: jake Date: Wed, 6 Nov 2024 12:23:03 -0800 Subject: [PATCH] fixed --parameters parsing --- internetarchive/cli/cli_utils.py | 7 ++++--- internetarchive/cli/ia_search.py | 9 +++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/internetarchive/cli/cli_utils.py b/internetarchive/cli/cli_utils.py index b7c2929f..2ad477e6 100644 --- a/internetarchive/cli/cli_utils.py +++ b/internetarchive/cli/cli_utils.py @@ -89,7 +89,7 @@ def validate_identifier(identifier): return identifier -def prepare_args_dict(args, parser, arg_type="metadata", many=False): +def prepare_args_dict(args, parser, arg_type="metadata", many=False, query_string=False): if not args: return {} try: @@ -97,9 +97,10 @@ def prepare_args_dict(args, parser, arg_type="metadata", many=False): return get_args_dict_many_write([item for sublist in args for item in sublist]) else: if isinstance(args[0], list): - return get_args_dict([item for sublist in args for item in sublist]) + return get_args_dict([item for sublist in args for item in sublist], + query_string=True) else: - return get_args_dict(args) + return get_args_dict(args, query_string=True) except ValueError as e: parser.error(f"--{arg_type} must be formatted as --{arg_type}='key:value'") diff --git a/internetarchive/cli/ia_search.py b/internetarchive/cli/ia_search.py index c840cda4..6a84962b 100644 --- a/internetarchive/cli/ia_search.py +++ b/internetarchive/cli/ia_search.py @@ -162,8 +162,13 @@ def main(args: argparse.Namespace, parser: argparse.ArgumentParser) -> None: """ try: # Validate args. - args.parameters = prepare_args_dict(args.parameters, parser=parser) - args.header = prepare_args_dict(args.header, parser=parser) + args.parameters = prepare_args_dict(args.parameters, + parser=parser, + arg_type='parameters', + query_string=True) + args.header = prepare_args_dict(args.header, + parser=parser, + arg_type='header') # Prepare fields and sorts. fields = prepare_values(args.field)