build.py 文件源码

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

项目:staticsite 作者: spanezz 项目源码 文件源码
def write_pages(self, pages):
        sums = defaultdict(float)
        counts = defaultdict(int)

        # group by type
        by_type = defaultdict(list)
        for page in pages:
            by_type[(page.RENDER_PREFERRED_ORDER, page.TYPE)].append(page)

        # Render collecting timing statistics
        for (order, type), pgs in sorted(by_type.items(), key=lambda x:x[0][0]):
            start = time.perf_counter()
            for page in pgs:
                contents = page.render()
                for relpath, rendered in contents.items():
                    dst = self.output_abspath(relpath)
                    rendered.write(dst)
            end = time.perf_counter()
            sums[type] = end - start
            counts[type] = len(pgs)
        return sums, counts
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号