queries.py 文件源码

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

项目:datapipelines-python 作者: meraki-analytics 项目源码 文件源码
def evaluate(self, query: MutableMapping[str, Any], context: PipelineContext = None) -> bool:
        # We can't short circuit this because we want to raise any WrongValueTypeError or BoundKeyExistenceError that could occur.
        # We count failures because the only other node than can return False is a KeyNode that isn't required. An OrNode is only
        # allowed to return False when all its children are False KeyNodes. The AndNodes handle raising an error if a can_have
        # expression with ands and ors fails.
        errors = []
        failure_count = 0
        result = False
        for child in self.children:
            try:
                is_true = child.evaluate(query, context)
                if not is_true:
                    failure_count += 1
                result = is_true or result
            except (MissingKeyError, BoundKeyExistenceError) as error:
                errors.append(error)
                failure_count += 1
        if failure_count == len(self.children) and len(errors) > 0:
            raise errors[0]
        return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号