inputdevices.py 文件源码

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

项目:rticonnextdds-logparser 作者: rticommunity 项目源码 文件源码
def print_progress(self, threshold=0, decimals=1, barLength=100):
        """Print a terminal progress bar."""
        # Based on @Greenstick's reply (https://stackoverflow.com/a/34325723)
        iteration = self.stream.tell()
        if iteration > self.file_size:
            return
        total = self.file_size
        if total == 0:
            return

        progress = 100.0 * iteration / total
        if self.progress and progress - self.progress < threshold:
            return

        self.progress = progress
        percents = ("%03." + str(decimals) + "f") % progress
        filledLength = int(round(barLength * iteration / float(total)))

        barText = '*' * filledLength + '-' * (barLength - filledLength)
        stdout.write('%s| %s%% Completed\r' % (barText, percents))
        stdout.flush()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号