1
2 """Parses Chemkin-Files"""
3
4
5
6 import sys
7
8 from FileBasis import FileBasisBackup
9 from PyFoam.Basics.PlyParser import PlyParser
10
12 """Overclass for the Chemkin-Parsers"""
13
15 """@param content: the string to be parsed
16 @param debug: output debug information during parsing"""
17
18 PlyParser.__init__(self,debug=debug)
19
20 - def printContext(self,c,ind):
21 """Prints the context of the current index"""
22 print "------"
23 print c[max(0,ind-100):max(0,ind-1)]
24 print "------"
25 print ">",c[ind-1],"<"
26 print "------"
27 print c[min(len(c),ind):min(len(c),ind+100)]
28 print "------"
29
31 """Prints the error message of the parser and exit"""
32 print "PARSER ERROR:",text
33 print "On index",ind
34 self.printContext(c,ind)
35 raise ParseError
36 sys.exit(-1)
37
38 tokens = (
39 'THERMO',
40 'ALL',
41 'END',
42 'ELEMENTS',
43 'SPECIE',
44 'REACTIONS',
45 )
46
48 """Parses a Chemkin-Thermo-File and makes it available"""
49
50 - def __init__(self,name,backup=False,debug=False):
51 """@param name: The name of the parameter file
52 @param backup: create a backup-copy of the file"""
53
54 FileBasisBackup.__init__(self,name,backup=backup)
55
57 """Class that parses a string that contains the contents of an
58 Chemkin-Thermo-file and builds a nested structure of directories and
59 lists from it"""
60
62 """@param content: the string to be parsed
63 @param debug: output debug information during parsing"""
64
65 ChemkinParser.__init__(self,content,debug=debug)
66
68 """Parses a Chemkin-Reaction-File and makes it available"""
69
70 - def __init__(self,name,backup=False,debug=False):
71 """@param name: The name of the parameter file
72 @param backup: create a backup-copy of the file"""
73
74 FileBasisBackup.__init__(self,name,backup=backup)
75
77 """Class that parses a string that contains the contents of an
78 Chemkin-Reactions-file and builds a nested structure of directories and
79 lists from it"""
80
81 - def __init__(self,content,debug=False,noHeader=False):
82 """@param content: the string to be parsed
83 @param debug: output debug information during parsing
84 @param noHeader: switch that turns off the parsing of the header"""
85
86 ChemkinParser.__init__(self,content,debug=debug)
87