From: Xaver W. <xav...@we...> - 2009-11-30 15:22:17
|
Hi guys, I've got a few questions about using cclib. Actually, Noel asked me to cc them here, but I thought it might make sense to generally discuss them here. I hope they're not too much "newbie-questions", because I'm not really advanced in programming and python. -In which case is the variable 'scfvalues' (not) created? I tried to get it with a couple of gaussian03 log files, but it was never existant. -When is cclib closing its input file? From my understanding of the source code, that should be done after parsing (?! logparser.py/line 145 in current stable), but it seems the files are still open when testing it in a python console. Just wondering if I have to do anything to cleanly have all files closed at the end of my code. - Can I trick cclib into reading a string instead of a file? Noel pointed me to StringIO objects. However, StringIO simulates an "opened file" while cclib needs a non-open file, right?: >>> mimicfile=StringIO.StringIO(" Entering Gaussian System, Link 0=/opt/g03/g03/g03\n SCF Done: E(UB+HF-LYP) = -887.172106755 A.U. after 59 cycles") >>> myfile = cclib.parser.Gaussian("mimicfile") >>> print myfile Gaussian log file mimicfile >>> myfile.parse() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.6/site-packages/cclib/parser/logfileparser.py", line 104, in parse inputfile = utils.openlogfile(self.filename) File "/usr/lib/python2.6/site-packages/cclib/parser/utils.py", line 61, in openlogfile fileobject = open(filename, "r") IOError: [Errno 2] No such file or directory: 'mimicfile' >>> cclib.parser.ccopen(mimicfile) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.6/site-packages/cclib/parser/utils.py", line 96, in ccopen for line in inputfile: File "/usr/lib/python2.6/fileinput.py", line 253, in next line = self.readline() File "/usr/lib/python2.6/fileinput.py", line 343, in readline self._file = self._openhook(self._filename, self._mode) File "/usr/lib/python2.6/fileinput.py", line 387, in hook_compressed return open(filename, mode) IOError: [Errno 2] No such file or directory: ' Entering Gaussian System, Link 0=/opt/g03/g03/g03\n' Thanks in advance, Xaver W. |