Permission to use, copy, modify, and/or distribute this software for any
purpose withor without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS"AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ORIN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """
# How long to wait before recalculating the ETA
ETA_INTERVAL = 1 # How many intervals (excluding the current one) to calculate the simple moving # average
ETA_SMA_WINDOW = 9
class Bar(object): def __enter__(self): return self
def bar(
it,
label="",
width=32,
hide=None,
empty_char=BAR_EMPTY_CHAR,
filled_char=BAR_FILLED_CHAR,
expected_size=None,
every=1,
): """Progress iterator. Wrap your iterables with it."""
count = len(it) if expected_size isNoneelse expected_size
with Bar(
label=label,
width=width,
hide=hide,
empty_char=empty_char,
filled_char=filled_char,
expected_size=count,
every=every,
) as bar: for i, item in enumerate(it): yield item
bar.show(i + 1)
def dots(it, label="", hide=None, every=1): """Progress iterator. Prints a dot for each item being iterated"""
count = 0
ifnot hide:
STREAM.write(label)
for i, item in enumerate(it): ifnot hide: if i % every == 0: # True every "every" updates
STREAM.write(DOTS_CHAR)
sys.stderr.flush()
count += 1
yield item
STREAM.write("\n")
STREAM.flush()
def mill(it, label="", hide=None, expected_size=None, every=1): """Progress iterator. Prints a mill while iterating over the items."""
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.