class ProgressBar(object): def __init__(self, limit, fmt): assert self.conservative_isatty()
self.prior = None
self.atLineStart = True # [{str:str}] Describtion of how to lay out each field in the counters map.
self.counters_fmt = fmt # int: The value of 'current' equal to 100%.
self.limit = limit # int: max digits in limit
self.limit_digits = int(math.ceil(math.log10(self.limit))) # datetime: The start time.
self.t0 = datetime.now() # datetime: Optional, the last time update() ran.
self.last_update_time = None
# Compute the width of the counters and build the format string.
self.counters_width = 1 # [ for layout in self.counters_fmt:
self.counters_width += self.limit_digits # | (or ']' for the last one)
self.counters_width += 1
def finish(self, complete=True): ifnot self.prior:
sys.stdout.write( "No test run... You can try adding" " --run-slow-tests or --run-skipped to run more tests\n"
) return
final_count = self.limit if complete else self.prior[0]
self.update(final_count, self.prior[1])
sys.stdout.write("\n")
@staticmethod def conservative_isatty(): """
Prefer erring on the side of caution andnot using terminal commands if
the current output stream may be a file. """ return sys.stdout.isatty()
Messung V0.5
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.