From: Xaver W. <xav...@we...> - 2009-12-04 16:38:11
|
Hi, OK, since you seem to be talking about the latest svn code, I got the latest revision now. > Let met just input on this at the moment. In fact cclib.parser.ccopen can > process an input stream, which can an open file object or instance of > StringIO.StringIO. Generally, whatever can be read and > implements 'read', 'next' and other methods. I don't get errors while Gaussian(stringiofile).parse(), so it seems to generally work. However, I don't get an scfenergies attribute from 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") , and ccopen() doesn't recognize it as Gaussian type. Well, I guess that's because cclib is not really made to handle small fake logfiles. As I don't have the time to test how to trick it, I think I'll take Karol's friendly offer and put sth like that as a feature request on sourceforge... (But first I'll wait if it is a bug that sometimes, I don't get an scfvalues attribute even for real gaussian03 log files. I'll post a bug report on that) > How did you test that the file is still open? I can't remember, but it doesn't matter. I'd just like to know if I have to 'do' sth to cleanly close my log files at the end of my program code. You know, sth like ccopen(myfile) ... ccclose(myfile) ...or does cclib handle this? Regards, Xaver Am Monday 30 November 2009 19:09:57 schrieb Karol M. Langner: > On Monday 30 November 2009 16:29:04 Noel O'Boyle wrote: > > > - 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") > > > > You passed the string mimicfile - you should pass the variable, e.g. > > Gaussian(mimicfile). However, cclib has been written to parse entire > > files, not portions of files, so this example may not work. > > Let met just input on this at the moment. In fact cclib.parser.ccopen can > process an input stream, which can an open file object or instance of > StringIO.StringIO. Generally, whatever can be read and > implements 'read', 'next' and other methods. > > >>> import cclib > >>> print cclib.parser.ccopen.__doc__ > > Guess the identity of a particular log file and return an instance of it. > > Inputs: > source - a single logfile, a list of logfiles, or an input stream > > Returns: > one of ADF, GAMESS, GAMESS UK, Gaussian, Jaguar, Molpro, ORCA, or > None (if it cannot figure it out or the file does not exist). > > Currently passing a string would generate an error, but that functionality > could be added quite easily. If needed, please file a feature request and > I'm sure Noel or I could implement it pretty fast. > > - Karol |