# -*- coding: utf-8 -*-## This file is subject to the terms and conditions defined in# file 'LICENSE.txt', which is part of this source code package.#fromtypingimportUnionfromMuscat.TypesimportMuscatIndex
[docs]defPrintProgressBar(iteration:Union[int,MuscatIndex],total:Union[int,MuscatIndex],prefix:str='',suffix:str='',decimals:int=1,length:int=100,fill:str='|')->None:""" Call in a loop to create terminal progress bar .. code-block:: python PrintProgressBar(0, l, prefix = 'Progress:', suffix = 'Complete', length = 50) for i, item in enumerate(items): # Do stuff... # Update Progress Bar PrintProgressBar(i + 1, l, prefix = 'Progress:', suffix = 'Complete', length = 50) Parameters ---------- iteration : int Current iteration total : int Total iterations prefix : str, optional Prefix string suffix : str, optional Suffix string decimals : int, optional Positive number of decimals in percent complete length : str, optional Character length of bar fill : str, optional Bar fill character """filledLength=int(length*iteration//total)# Print New Line on Completeend='\n'ifiteration==totalelse'\r'print(f"\r{prefix} |{fill*filledLength}{'-'*(length-filledLength)}| {100*iteration/total:.{decimals}f}% {suffix}",end=end,flush=True)
[docs]defCheckIntegrity(GUI:bool=False)->str:fromtimeimportsleep# A List of Itemsitems=list(range(0,57))l=len(items)# Initial call to print 0% progressPrintProgressBar(0,l,prefix='Progress:',suffix='Complete',length=50)fori,iteminenumerate(items):# Do stuff...sleep(0.001)# Update Progress BarPrintProgressBar(i+1,l,prefix='Progress:',suffix='Complete',length=50)return'ok'
if__name__=='__main__':CheckIntegrity(True)# pragma: no cover