Python progressbar 模块,SimpleProgress() 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用progressbar.SimpleProgress()

项目:fabric8-analytics-tagger    作者:fabric8-analytics    | 项目源码 | 文件源码
def progressbarize(iterable, progress=False):
    """Construct progressbar for loops if progressbar requested, otherwise return directly iterable.

    :param iterable: iterable to use
    :param progress: True if print progressbar
    """
    if progress:
        # The casting to list is due to possibly yielded value that prevents
        # ProgressBar to compute overall ETA
        return progressbar.ProgressBar(widgets=[
            progressbar.Timer(), ', ',
            progressbar.Percentage(), ', ',
            progressbar.SimpleProgress(), ', ',
            progressbar.ETA()
        ])(list(iterable))

    return iterable
项目:esper    作者:scanner-research    | 项目源码 | 文件源码
def progress_bar(n):
    import progressbar
    return progressbar.ProgressBar(
        max_value=n,
        widgets=[
            progressxbar.Percentage(),
            ' ',
            '(',
            progressbar.SimpleProgress(),
            ')',
            ' ',
            progressbar.Bar(),
            ' ',
            progressbar.AdaptiveETA(),
        ])


# http://code.activestate.com/recipes/577058/
项目:InstaLooter    作者:althonos    | 项目源码 | 文件源码
def _init_pbar(self, ini_val, max_val, label):
        self._pbar = progressbar.ProgressBar(
            min_value=0,
            max_value=max_val,
            initial_value=ini_val,
            widgets=[
                label,
                progressbar.Percentage(),
                '(', progressbar.SimpleProgress(), ')',
                progressbar.Bar(),
                progressbar.Timer(), ' ',
                '|', progressbar.ETA(),
            ]
        )
        self._pbar.start()
项目:saw_release    作者:kovibalu    | 项目源码 | 文件源码
def iterator_progress_bar(iterator, maxval=None):
    """ Returns an iterator for an iterator that renders a progress bar with a
    countdown timer. """

    from progressbar import ProgressBar, SimpleProgress, Bar, ETA
    pbar = ProgressBar(
        maxval=maxval,
        widgets=[SimpleProgress(sep='/'), ' ', Bar(), ' ', ETA()],
    )
    return pbar(iterator)