check.py 文件源码

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

项目:DjangoCMS 作者: farhan711 项目源码 文件源码
def _load_all_templates(directory):
    """
    Loads all templates in a directory (recursively) and yields tuples of
    template tokens and template paths.
    """
    if os.path.exists(directory):
        for name in os.listdir(directory):
            path = os.path.join(directory, name)
            if os.path.isdir(path):
                for template in _load_all_templates(path):
                    yield template
            elif path.endswith('.html'):
                with open(path, 'rb') as fobj:
                    source = fobj.read().decode(settings.FILE_CHARSET)
                    if DJANGO_1_8:
                        lexer = Lexer(source, path)
                    else:
                        lexer = Lexer(source)
                    yield lexer.tokenize(), path
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号