From: <ate...@us...> - 2006-03-22 00:06:43
|
Revision: 38 Author: atenderholt Date: 2006-03-21 16:06:38 -0800 (Tue, 21 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=38&view=rev Log Message: ----------- Work on the text progress Modified Paths: -------------- trunk/src/cclib/parser/g03parser.py trunk/src/cclib/parser/logfileparser.py trunk/src/cclib/parser/textprogress.py Modified: trunk/src/cclib/parser/g03parser.py =================================================================== --- trunk/src/cclib/parser/g03parser.py 2006-03-21 18:40:26 UTC (rev 37) +++ trunk/src/cclib/parser/g03parser.py 2006-03-22 00:06:38 UTC (rev 38) @@ -38,7 +38,7 @@ """Return a representation of the object.""" return 'G03("%s")' % (self.filename) - def parse(self): + def parse(self,fupdate=0.05,cupdate=0.002): """Extract information from the logfile.""" inputfile = open(self.filename,"r") @@ -52,15 +52,21 @@ for line in inputfile: - if self.progress and random.random()<0.05: + if self.progress and random.random()<cupdate: step = inputfile.tell() if step!=oldstep: - self.progress.update(step) + self.progress.update(step,"Unsupported Information") oldstep = step if line[1:8]=="NAtoms=": # Find the number of atoms + if self.progress and random.random()<fupdate: + step = inputfile.tell() + if step!=oldstep: + self.progress.update(step,"Attributes") + oldstep=step + natom = int(line.split()[1]) if hasattr(self,"natom"): assert self.natom==natom @@ -73,6 +79,12 @@ or line[25:45]=="Standard orientation" or line[26:43]=="Input orientation"): # Extract the atomic numbers of the atoms + if self.progress and random.random()<cupdate: + step = inputfile.tell() + if step!=oldstep: + self.progress.update(step,"Attributes") + oldstep=step + self.logger.info("Creating attribute atomnos[]") self.atomnos = [] hyphens = inputfile.next() @@ -102,6 +114,12 @@ if line[1:10]=='Cycle 1': # Extract SCF convergence information (QM calcs) + if self.progress and random.random()<fupdate: + step=inputfile.tell() + if step!=oldstep: + self.progress.update(step,"QM Convergence") + oldstep=step + if not hasattr(self,"scfvalues"): self.logger.info("Creating attribute scfvalues") self.scfvalues = [] @@ -132,6 +150,12 @@ if line[1:4]=='It=': # Extract SCF convergence information (AM1 calcs) + if self.progress: + step=inputfile.tell() + if step!=oldstep: + self.progress.update(step,"AM1 Convergence") + oldstep=step + self.logger.info("Creating attributes scftargets, scfvalues") self.scftargets = Numeric.array([1E-7],"f") # This is the target value for the rms self.scfvalues = [[]] @@ -171,6 +195,12 @@ if line[1:19]=='Orbital symmetries' and not hasattr(self,"mosyms"): # Extracting orbital symmetries + if self.progress and random.random()<fupdate: + step=inputfile.tell() + if step!=oldstep: + self.progress.update(step,"MO Symmetries") + oldstep=step + self.logger.info("Creating attribute mosyms[[]]") self.mosyms = [[]] line = inputfile.next() @@ -205,6 +235,12 @@ if line[1:6]=="Alpha" and line.find("eigenvalues")>=0: # Extract the alpha electron eigenvalues + if self.progress and random.random()<fupdate: + step=inputfile.tell() + if step!=oldstep: + self.progress.update(step,"Eigenvalues") + oldstep=step + self.logger.info("Creating attribute moenergies[[]]") self.moenergies = [[]] HOMO = -2 @@ -251,6 +287,12 @@ if line[1:14]=="Harmonic freq": # Start of the IR/Raman frequency section + if self.progress and random.random()<fupdate: + step=inputfile.tell() + if step!=oldstep: + self.progress.update(step,"Frequency Information") + oldstep=step + self.vibsyms = [] self.vibirs = [] self.vibfreqs = [] @@ -403,6 +445,13 @@ base = 0 colmNames = inputfile.next() while base<self.nbasis: + + if self.progress and random.random()<fupdate: + step=inputfile.tell() + if step!=oldstep: + self.progress.update(step,"Overlap") + oldstep=step + for i in range(self.nbasis-base): # Fewer lines this time line = inputfile.next() parts = line.split() @@ -428,6 +477,13 @@ base = 0 for base in range(0,nindep,5): + + if self.progress: + step=inputfile.tell() + if step!=oldstep and random.random() < fupdate: + self.progress.update(step,"Coefficients") + oldstep=step + colmNames = inputfile.next() symmetries = inputfile.next() eigenvalues = inputfile.next() @@ -452,7 +508,9 @@ inputfile.close() - + if self.progress: + self.progress.update(nstep,"Done") + if hasattr(self,"geovalues"): self.geovalues = Numeric.array(self.geovalues,"f") if hasattr(self,"scfenergies"): self.scfenergies = Numeric.array(self.scfenergies,"f") if hasattr(self,"scfvalues"): self.scfvalues = Numeric.array(self.scftargets,"f") Modified: trunk/src/cclib/parser/logfileparser.py =================================================================== --- trunk/src/cclib/parser/logfileparser.py 2006-03-21 18:40:26 UTC (rev 37) +++ trunk/src/cclib/parser/logfileparser.py 2006-03-22 00:06:38 UTC (rev 38) @@ -97,7 +97,7 @@ # Set up the logger self.logger = logging.getLogger('%s %s' % (self.logname,self.filename)) - self.logger.setLevel(logging.INFO) + self.logger.setLevel(self.loglevel) handler = logging.StreamHandler(sys.stdout) handler.setFormatter(logging.Formatter("[%(name)s %(levelname)s] %(message)s")) self.logger.addHandler(handler) Modified: trunk/src/cclib/parser/textprogress.py =================================================================== --- trunk/src/cclib/parser/textprogress.py 2006-03-21 18:40:26 UTC (rev 37) +++ trunk/src/cclib/parser/textprogress.py 2006-03-22 00:06:38 UTC (rev 38) @@ -1,3 +1,5 @@ +import sys +import thread class TextProgress: @@ -7,29 +9,38 @@ self.text=None self.oldprogress=0 self.progress=0 + self.calls=0 def initialize(self,nstep,text=None): self.nstep=float(nstep) self.text=text + + #sys.stdout.write("\n") - def update(self,step): + def update(self,step,text=None): + + self.progress = int(step*100/self.nstep) - self.progress = int(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 + if self.progress/2>=self.oldprogress/2+1 or self.text!=text: #just went through at least 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+="]" + str="\r[" + prog=self.progress/10 + str+=prog*"="+(10-prog)*"-" + str+="] %3i"%(self.progress)+"%" - print str + if text: + str+=" Parsing "+text + + sys.stdout.write("\r"+70*" ") + sys.stdout.flush() + sys.stdout.write(str) + sys.stdout.flush() + self.oldprogress=self.progress - self.oldprogress=self.progress + if(self.progress>=100 and text=="Done"): + print " " + + return This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |