Pmw.py 文件源码

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

项目:ecel 作者: ARL-UTEP-OC 项目源码 文件源码
def _validate(self):
        dict = {
            'validator' : None,
            'min' : None,
            'max' : None,
            'minstrict' : 1,
            'maxstrict' : 1,
        }
        opt = self['validate']
        if type(opt) is types.DictionaryType:
            dict.update(opt)
        else:
            dict['validator'] = opt

        # Look up validator maps and replace 'validator' field with
        # the corresponding function.
        validator = dict['validator']
        valFunction = self._getValidatorFunc(validator, 0)
        self._checkValidateFunction(valFunction, 'validate', validator)
        dict['validator'] = valFunction

        # Look up validator maps and replace 'stringtovalue' field
        # with the corresponding function.
        if dict.has_key('stringtovalue'):
            stringtovalue = dict['stringtovalue'] 
            strFunction = self._getValidatorFunc(stringtovalue, 1)
            self._checkValidateFunction(
                    strFunction, 'stringtovalue', stringtovalue)
        else:
            strFunction = self._getValidatorFunc(validator, 1)
            if strFunction == validator:
                strFunction = len
        dict['stringtovalue'] = strFunction

        self._validationInfo = dict
        args = dict.copy()
        del args['validator']
        del args['min']
        del args['max']
        del args['minstrict']
        del args['maxstrict']
        del args['stringtovalue']
        self._validationArgs = args
        self._previousText = None

        if type(dict['min']) == types.StringType and strFunction is not None:
            dict['min'] = apply(strFunction, (dict['min'],), args)
        if type(dict['max']) == types.StringType and strFunction is not None:
            dict['max'] = apply(strFunction, (dict['max'],), args)

        self._checkValidity()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号