def _parse_args_and_kwargs(passed_args):
args = []
kwargs = {}
has_kwargs = False
while len(passed_args) > 0:
arg = passed_args.pop(0)
if arg[:2] == '--':
has_kwargs = True
if not len(passed_args) > 0:
raise ValueError('Argument "{}" not recognized'.format(arg))
kwargs[arg[2:]] = passed_args.pop(0)
else:
if has_kwargs:
raise ValueError(
'Positional argument "{}" after keyword arguments'.format(
arg))
args.append(arg)
return args, kwargs
评论列表
文章目录