argument_datatype_class.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:warriorframework 作者: warriorframework 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号