1 """Data structures in Foam-Files that can't be directly represented by Python-Structures"""
2
3 import FoamFileGenerator
4 from copy import deepcopy
5 import string
6
9 return "'"+str(self)+"'"
10
11
12 -class Field(FoamDataType):
14 self.val=val
15 self.name=name
16 if self.name==None:
17 self.uniform=True
18 elif type(val) in[list,UnparsedList]:
19 self.uniform=False
20
29
31 if other==None:
32 return 1
33 if self.uniform!=other.uniform:
34 return cmp(self.uniform,other.uniform)
35 elif self.name!=other.name:
36 return cmp(self.name,other.name)
37 else:
38 return cmp(self.val,other.val)
39
41 assert(not self.uniform)
42 return self.val[key]
43
45 assert(not self.uniform)
46 self.val[key]=value
47
50
53
58
61 assert(len(dims)==7)
62 self.dims=list(dims)
63
65 result="[ "
66 for v in self.dims:
67 result+=str(v)+" "
68 result+="]"
69 return result
70
72 if other==None:
73 return 1
74 return cmp(self.dims,other.dims)
75
78
81
85
87 return "("+string.join(map(lambda v:"%g"%v,self.vals))+")"
88
90 if other==None:
91 return 1
92 return cmp(self.vals,other.vals)
93
96
99
101 return len(self.vals)
102
106
108 - def __init__(self,v1,v2,v3,v4,v5,v6,v7,v8,v9):
110
114
116 """A class that acts like a dictionary, but preserves the order
117 of the entries. Used to beautify the output"""
118
120 dict.__init__(self)
121 self._order=[]
122
124 dict.__setitem__(self,key,value)
125 if key not in self._order:
126 self._order.append(key)
127
129 dict.__delitem__(self,key)
130 self._order.remove(key)
131
133 new=DictProxy()
134 for k in self._order:
135 new[k]=deepcopy(self[k],memo)
136 return new
137
139 """Enables Tuples to be manipulated"""
140
143
145 """A class that encapsulates an unparsed string"""
146
149
152
154 """A class that encapsulates a list that was not parsed for
155 performance reasons"""
156
158 self.data=data
159 self.length=lngth
160
163
165 return cmp(self.data,other.data)
166