utils.py 文件源码

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

项目:SNH48Live 作者: SNH48Live 项目源码 文件源码
def update(self, pos, *, force=False):
        self._pos = pos
        if not self._activated:
            return
        if not force and time.time() - self._updated < self._update_threshold:
            return
        percentage = int(pos / self._total * 100)
        term_width, _ = shutil.get_terminal_size()
        bar_length = max(40, term_width - 1 - self._static_length)
        filled_length = max(int(bar_length * pos / self._total), 1)
        bar = '=' * (filled_length - 1) + '>' + ' ' * (bar_length - filled_length)
        sys.stderr.write(self._fmt.format(
            pos=pos, bar=bar, percentage=percentage,
        ))
        self._updated = time.time()

    # After calling done(), call activate() to redraw and re-activate the bar.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号