Package PyFoam :: Package Basics :: Module ProgressOutput
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Basics.ProgressOutput

 1  """Output of progress""" 
 2   
3 -class ProgressOutput(object):
4 """This class generates output for recording the progress""" 5
6 - def __init__(self,oFile):
7 """@param oFile: file-type object that gets the progress output""" 8 self.oFile=oFile 9 self.oLen=0 10 self.storedLen=0
11
12 - def reset(self):
13 """reset for the next time""" 14 if self.storedLen>self.oLen: 15 # clear residual fro mprevious outputs 16 self.oFile.write(" "*(self.storedLen-self.oLen)) 17 18 self.oFile.write("\r") 19 self.oFile.flush() 20 21 self.storedLen=self.oLen 22 self.oLen=0
23
24 - def __call__(self,msg):
25 """Add to the progress message 26 @param msg: the text to add""" 27 self.oFile.write(" "+msg) 28 self.oFile.flush() 29 self.oLen+=len(msg)+1
30