From e5173311dd4c37de3803aae6949520c7e508e23b Mon Sep 17 00:00:00 2001 From: lukemartinlogan Date: Fri, 23 Feb 2024 10:07:40 -0600 Subject: [PATCH] Make yaml less important --- jarvis_util/util/argparse.py | 5 ++++- test/unit/test_argparse.py | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/jarvis_util/util/argparse.py b/jarvis_util/util/argparse.py index 71fb07e..4aedeb4 100644 --- a/jarvis_util/util/argparse.py +++ b/jarvis_util/util/argparse.py @@ -449,7 +449,10 @@ def _convert_opt(self, opt, arg): try: if opt_type is list: if isinstance(arg, str): - arg = yaml.safe_load(arg) + try: + arg = yaml.safe_load(arg) + except: + pass if not isinstance(arg, list): if arg is None: arg = [] diff --git a/test/unit/test_argparse.py b/test/unit/test_argparse.py index 02c169c..f18afd2 100644 --- a/test/unit/test_argparse.py +++ b/test/unit/test_argparse.py @@ -155,6 +155,12 @@ def test_list_arg4(self): self.assertEqual(15, args.kwargs['steps']) self.assertEqual([], args.kwargs['hosts']) + def test_list_arg5(self): + args = MyArgParse( + args='vpic run 15 --hosts="*.hdf5" --hosts="*.h5"') + self.assertEqual(15, args.kwargs['steps']) + self.assertEqual(['*.hdf5', '*.h5'], args.kwargs['hosts']) + def test_list_list_arg(self): args = MyArgParse(args='vpic run 15 ' '--devices=\"[[nvme, 5], [sata, 25]]\"')