def convert_string_to_datatype(self):
"""Converts an input string to a python datatype """
err_msg = "User input argument value {0} does"\
"not match python syntax for '{1}'".format(self.arg_value, self.datatype)
info_msg = "Warrior FW will handle user input argument value as string (default)"
try:
result = ast.literal_eval(self.arg_value)
except Exception:
print '\n'
print_error(err_msg)
print_info(info_msg)
print '\n'
print_error('unexpected error: {0}'.format(traceback.format_exc()))
result = self.arg_value
else:
if not isinstance(result, self.datatype):
print '\n'
print_error(err_msg)
print_info(info_msg)
print '\n'
result = self.arg_value
return result
argument_datatype_class.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录