models.py 文件源码

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

项目:FMBlog 作者: vc12345679 项目源码 文件源码
def get_blog(cls, file_name):
        if cls.is_exist(file_name):
            with open(cls._real_file_name(file_name), 'r', encoding='utf-8') as f:
                txt = f.read()
            mtime = os.path.getmtime(cls._real_file_name(file_name))
            from bs4 import BeautifulSoup, Comment
            import yaml
            comment = BeautifulSoup(txt, "html.parser").find(text=lambda text: isinstance(text, Comment))
            if comment is not None:
                blog_info = yaml.load(comment)
                if 'use_toc' not in blog_info:
                    blog_info['use_toc'] = False
                    html = markdown(txt)
                    return blog_info, txt, html, mtime
            else:
                return
        else:
            return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号