parser.py 文件源码

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

项目:django-apiblueprint-view 作者: chris48s 项目源码 文件源码
def _replace_includes(self, apibp):
        matches = re.findall(r'<!-- include\((.*)\) -->', apibp)
        for match in matches:
            include_path = safe_join(os.path.dirname(self.blueprint), match)

            if not self._is_whitelisted(include_path):
                raise SuspiciousFileOperation("extension not in whitelist")

            # recursively replace any includes in child files
            include_apibp = self._replace_includes(
                open(include_path, 'r').read())

            apibp = apibp.replace(
                '<!-- include(' + match + ') -->', include_apibp)

        return apibp
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号