def parse_argv_module_args(argv,module_arg_names):
baseline_args = ['module_name','lsid','cache_path','execution_id','cwd','module_libdir','sg_prepare_template']
arg_names = baseline_args + module_arg_names
arg_names2 = [argname + '=' for argname in arg_names]
(param_value_pairs,remnants)=getopt.getopt(argv,"",arg_names2)
if len(remnants)>0:
raise Exception ("unrecognized arguments %s"%str(remnants))
arg_param_value_dict = {}
missing_args = set(module_arg_names)
for arg_pair in param_value_pairs:
param_name = arg_pair[0][2:] #strip off '--' at start
param_value = arg_pair[1]
if param_name not in module_arg_names:
continue
missing_args.remove(param_name)
if param_name in arg_param_value_dict:
raise Exception('duplicated param name %s'%param_name)
arg_param_value_dict[param_name]=param_value
missing_args = list(missing_args)
return (arg_param_value_dict,missing_args)
run_module.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录