iot-with-document-store-db

git clone git://git.codymlewis.com/iot-with-document-store-db.git
Log | Files | Refs | README

Functions.py (830B)


      1 '''
      2 A few utility functions.
      3 
      4 Author: Cody Lewis
      5 Date: 2019-03-30
      6 '''
      7 
      8 
      9 def print_progress(current_epoch, total_epochs, progress_len=31, prefix="", suffix=""):
     10     '''
     11     Print a progress bar about how far a process has went through it's epochs.
     12     '''
     13     progress = int(100 * current_epoch / total_epochs)
     14 
     15     progress_bar_progress = int(progress_len * progress * 0.01)
     16     if progress_bar_progress != 0:
     17         unprogressed = progress_len - progress_bar_progress
     18     else:
     19         unprogressed = progress_len - 1
     20     progress_bar = "["
     21     progress_bar += "".join(
     22         ["=" for _ in range(progress_bar_progress - 2)] + [">" if unprogressed > 0 else "="]
     23     )
     24     progress_bar += "".join(["." for _ in range(unprogressed)])
     25     progress_bar += "]"
     26     print(f"\r{prefix} {progress_bar} {progress}% {suffix}", end="\r")