def make_list_of_values(allowed):
"""
Take a list of allowed values for an option and return a function that can be
used to typecheck a string of given values and ensure they match the allowed
values. This is required to support options that take comma separated lists
such as --rights in 'tenant set --rights=create,delete,mount'
"""
def list_of_values(string):
given = string.split(',')
for g in given:
if g not in allowed:
msg = (
'invalid choices: {0} (choices must be a comma separated list of '
'only the following words \n {1}. '
'No spaces are allowed between choices.)').format(g, repr(allowed).replace(' ', ''))
raise argparse.ArgumentTypeError(msg)
return given
return list_of_values
vmdkops_admin.py 文件源码
python
阅读 29
收藏 0
点赞 0
评论 0
评论列表
文章目录