console.py 文件源码

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

项目:django-powerpages 作者: Open-E-WEB 项目源码 文件源码
def format_message(self, current, total):
        """Creates message to be written on console"""
        if total:
            ratio = float(current) / total
            filled_bricks = int((ratio + 0.05) * self.progress_num_bricks)
            num_digits = int(math.log10(total))
        else:
            ratio = 1.0
            filled_bricks = self.progress_num_bricks
            num_digits = 1
        last_step = total == current
        if last_step:
            eta = datetime.timedelta(0)
        elif ratio and self.start_datetime:
            total_seconds_ = total_seconds(
                datetime.datetime.now() - self.start_datetime
            )
            eta = datetime.timedelta(
                seconds=total_seconds_ / ratio - total_seconds_
            )
        else:
            eta = '?'
        screw = " " if last_step else next(self.screw_cycle)
        return self.line_template.format(
            bricks=self.progress_brick * filled_bricks,
            num_bricks=self.progress_num_bricks,
            ratio=ratio,
            current=current,
            total=total,
            num_digits=num_digits,
            eta=eta,
            screw=screw
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号