我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用progressbar.Counter()。
def __init__(self, *args, **kwargs): self.dld = FileDownloader() self.dld.stage(self.cmd_name) load_continents() load_oceans() load_currencies() load_languages() self.widgets = [ MemoryUsage(), progressbar.ETA(), ' |Processed: ', progressbar.Counter(), ' |Done: ', progressbar.Percentage(), progressbar.Bar(), ] return super().__init__(*args, **kwargs)
def _setup_progress(self, options): if options.progress: if self.beanstalk: # With Beanstalk C&C we don't know how many... self.progress = progressbar.ProgressBar( redirect_stdout=True, redirect_stderr=True, widgets=[ 'Total: ', progressbar.Counter(), ', ', progressbar.Timer() ]) else: self.progress = progressbar.ProgressBar( redirect_stdout=True, redirect_stderr=True, widgets=[ progressbar.Percentage(), progressbar.Bar(), ' (', progressbar.ETA(), ') ', ]) else: self.progress = None
def bar_update(self, epoch, logs): ologs = {} for k in self.custom_log_functions: ologs[k] = self.custom_log_functions[k]() for k in logs: if len(k) > 5: ologs[k[-5:]] = logs[k] else: ologs[k] = logs[k] if not hasattr(self,'bar'): import progressbar widgets = [ progressbar.Timer(format='%(elapsed)s'), ' ', progressbar.Counter(), progressbar.Bar(), progressbar.AbsoluteETA(format='%(eta)s'), ' ', ] keys = [] for k in ologs: keys.append(k) keys.sort() for k in keys: widgets.append(progressbar.DynamicMessage(k)) widgets.append(' ') self.bar = progressbar.ProgressBar(max_value=self.max_epoch, widgets=widgets) self.bar.update(epoch+1, **ologs)
def create_progress_bar(message): widgets = [ message, progressbar.Counter(), ' ', progressbar.Percentage(), ' ', progressbar.Bar(), progressbar.AdaptiveETA() ] pbar = progressbar.ProgressBar(widgets=widgets) return pbar
def bar(ndigits=3, **kwargs): if progressbar.__version__ > '3': counterfmt = '%(value)'+str(ndigits)+'d' else: counterfmt = '%'+str(ndigits)+'d' pbar = IncrementingProgressBar(widgets=[ progressbar.Percentage(), '|', progressbar.Counter(counterfmt), progressbar.Bar(), progressbar.ETA()], **kwargs) return pbar