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]]\"')