From: <bao...@us...> - 2006-03-07 09:52:30
|
Revision: 6 Author: baoilleach Date: 2006-03-07 01:52:22 -0800 (Tue, 07 Mar 2006) ViewCVS: http://svn.sourceforge.net/cclib/?rev=6&view=rev Log Message: ----------- Separated G03 from Logfile. Modified Paths: -------------- trunk/src/cclib/parser/G03.py Added Paths: ----------- trunk/src/cclib/parser/Logfile.py trunk/src/cclib/parser/__init__.py Modified: trunk/src/cclib/parser/G03.py =================================================================== --- trunk/src/cclib/parser/G03.py 2006-03-07 09:49:10 UTC (rev 5) +++ trunk/src/cclib/parser/G03.py 2006-03-07 09:52:22 UTC (rev 6) @@ -19,45 +19,8 @@ """ import math,sys,logging,copy,re,os,time # How many of these are necessary? import Numeric +from Logfile import Logfile # import the superclass -def convertor(value,fromunits,tounits): - """Convert from one set of units to another. - - >>> convertor(8,"eV","cm-1") - 64000 - """ - _convertor = {"eV_to_cm-1": lambda x: x*8065.6, - "nm_to_cm-1": lambda x: 1e7/x, - "cm-1_to_nm": lambda x: 1e7/x} - - return _convertor["%s_to_%s" % (fromunits,tounits)] (value) - -class PeriodicTable(object): - """Allows conversion between element name and atomic no. - - >>> t = PeriodicTable() - >>> t.element[6] - 'C' - >>> t.number['C'] - 6 - """ - def __init__(self): - self.element = [None,"H","He","Li","Be","B","C","N","O","F","Ne"] - self.number = {} - for i in range(1,len(self.element)): - self.number[self.element[i]] = i - -class Logfile(object): - """Abstract class that contains the methods that act on data - parsed from various types of logfile.""" - def __init__(self,filename): - self.filename = filename - - def float(self,number): - """Convert a string to a float avoiding the problem with Ds.""" - number = number.replace("D","E") - return float(number) - class G03(Logfile): """A Gaussian 03 log file Copied: trunk/src/cclib/parser/Logfile.py (from rev 5, trunk/src/cclib/parser/G03.py) =================================================================== --- trunk/src/cclib/parser/Logfile.py (rev 0) +++ trunk/src/cclib/parser/Logfile.py 2006-03-07 09:52:22 UTC (rev 6) @@ -0,0 +1,63 @@ +""" +cclib is a parser for computational chemistry log files. + +See http://cclib.sf.net for more information. + +Copyright (C) 2006 Noel O'Boyle and Adam Tenderholt + + This program is free software; you can redistribute and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY, without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + +Contributions (monetary as well as code :-) are encouraged. +""" +import math,sys,logging,copy,re,os,time # How many of these are necessary? +import Numeric + +def convertor(value,fromunits,tounits): + """Convert from one set of units to another. + + >>> convertor(8,"eV","cm-1") + 64000 + """ + _convertor = {"eV_to_cm-1": lambda x: x*8065.6, + "nm_to_cm-1": lambda x: 1e7/x, + "cm-1_to_nm": lambda x: 1e7/x} + + return _convertor["%s_to_%s" % (fromunits,tounits)] (value) + +class PeriodicTable(object): + """Allows conversion between element name and atomic no. + + >>> t = PeriodicTable() + >>> t.element[6] + 'C' + >>> t.number['C'] + 6 + """ + def __init__(self): + self.element = [None,"H","He","Li","Be","B","C","N","O","F","Ne"] + self.number = {} + for i in range(1,len(self.element)): + self.number[self.element[i]] = i + +class Logfile(object): + """Abstract class that contains the methods that act on data + parsed from various types of logfile.""" + def __init__(self,filename): + self.filename = filename + + def float(self,number): + """Convert a string to a float avoiding the problem with Ds.""" + number = number.replace("D","E") + return float(number) + +if __name__=="__main__": + import doctest,parser + doctest.testmod(parser,verbose=False) Added: trunk/src/cclib/parser/__init__.py =================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |