analyzer.py 文件源码

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

项目:chalice 作者: aws 项目源码 文件源码
def _is_chalice_view(self, node):
        # type: (ast.FunctionDef) -> bool
        # We can certainly improve on this, but this check is more
        # of a heuristic for the time being.  The ideal way to do this
        # is to infer the Chalice type and ensure the function is
        # decorated with the Chalice type's route() method.
        decorator_list = node.decorator_list
        if not decorator_list:
            return False
        for decorator in decorator_list:
            if isinstance(decorator, ast.Call) and \
                    isinstance(decorator.func, ast.Attribute):
                if decorator.func.attr == 'route' and \
                        decorator.args:
                    return True
                # For lambda_function and schedule decorator.args
                # not present.
                if decorator.func.attr in ('lambda_function', 'schedule'):
                    return True
        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号