From: <ate...@us...> - 2006-03-09 19:54:26
|
Revision: 14 Author: atenderholt Date: 2006-03-09 11:54:18 -0800 (Thu, 09 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=14&view=rev Log Message: ----------- Initial work on progress dialog support Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py trunk/src/cclib/parser/logfileparser.py Added Paths: ----------- trunk/src/cclib/parser/textprogress.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-03-09 09:54:04 UTC (rev 13) +++ trunk/src/cclib/parser/g03parser.py 2006-03-09 19:54:18 UTC (rev 14) @@ -24,10 +24,10 @@ class G03(Logfile): """A Gaussian 98/03 log file""" SCFRMS,SCFMAX,SCFENERGY = range(3) # Used to index self.scftargets[] - def __init__(self,filename): + def __init__(self,*args): # Call the __init__ method of the superclass - super(G03, self).__init__(filename) + super(G03, self).__init__(*args) # Set up the logger...will move this into superclass # through a function call with G03 as a parameter. @@ -50,8 +50,24 @@ def parse(self): """Extract information from the logfile.""" inputfile = open(self.filename,"r") + + if self.progress: + + inputfile.seek(0,2) #go to end of file + nstep=inputfile.tell() + inputfile.seek(0) + self.progress.initialize(nstep) + self.oldstep=0 + for line in inputfile: + if self.progress: + + step=inputfile.tell() + if not (step==self.oldstep): + self.progress.update(step) + self.oldstep=step + if line[1:8]=="NAtoms=": # Find the number of atoms natom = int(line.split()[1]) Modified: trunk/src/cclib/parser/logfileparser.py =================================================================== --- trunk/src/cclib/parser/logfileparser.py 2006-03-09 09:54:04 UTC (rev 13) +++ trunk/src/cclib/parser/logfileparser.py 2006-03-09 19:54:18 UTC (rev 14) @@ -71,6 +71,7 @@ natom -- number of atoms nbasis -- number of basis functions nindep -- number of linearly-independent basis functions + progress -- class (or None) for handling progress info scftargets -- targets for convergence of the SCF scfvalues -- current values for convergence of the SCF vibfreqs -- vibrational frequencies @@ -78,8 +79,9 @@ vibramans -- Raman intensity vibsyms -- symmetry of vibrations """ - def __init__(self,filename): + def __init__(self,filename,progress=None): self.filename = filename + self.progress = progress def float(self,number): """Convert a string to a float avoiding the problem with Ds.""" Added: trunk/src/cclib/parser/textprogress.py =================================================================== --- trunk/src/cclib/parser/textprogress.py (rev 0) +++ trunk/src/cclib/parser/textprogress.py 2006-03-09 19:54:18 UTC (rev 14) @@ -0,0 +1,35 @@ + +class TextProgress: + + def __init__(self): + + self.nstep=0 + self.text=None + self.oldprogress=0 + self.progress=0 + + def initialize(self,nstep,text=None): + + self.nstep=float(nstep) + self.text=text + + def update(self,step,newtext=None): + + self.progress=int(float(step)/self.nstep*100) + #print step,self.nstep + + if(self.progress/10==self.oldprogress/10+1): #just went through an interval of ten, ie. from 39 to 41, so update + + str="[" + for i in range(self.progress/10): + str+="=" + for i in range(self.progress/10,10): + str+="-" + + str+="]" + + print str + + self.oldprogress=self.progress + return + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |