pyslha.py

changeset 141
869c16f9093b
parent 140
81b5c01084f4
child 144
c549f909067c
equal deleted inserted replaced
140:81b5c01084f4 141:869c16f9093b
194 line = line[:line.index("#")] 194 line = line[:line.index("#")]
195 195
196 ## Handle BLOCK/DECAY start lines 196 ## Handle BLOCK/DECAY start lines
197 if line.upper().startswith("BLOCK"): 197 if line.upper().startswith("BLOCK"):
198 #print line 198 #print line
199 match = re.match(r"BLOCK\s+(\w+)(\s+Q=\s*.+)?", line.upper()) 199 match = re.match(r"BLOCK\s+(\w+)(\s+Q\s*=\s*.+)?", line.upper())
200 if not match: 200 if not match:
201 continue 201 continue
202 blockname = match.group(1) 202 blockname = match.group(1)
203 qstr = match.group(2) 203 qstr = match.group(2)
204 if qstr is not None: 204 if qstr is not None:
205 qstr = qstr[2:].strip() 205 qstr = qstr[qstr.find("=")+1:].strip()
206 currentblock = blockname 206 currentblock = blockname
207 currentdecay = None 207 currentdecay = None
208 blocks[blockname] = Block(blockname, q=qstr) 208 blocks[blockname] = Block(blockname, q=qstr)
209 elif line.upper().startswith("DECAY"): 209 elif line.upper().startswith("DECAY"):
210 match = re.match(r"DECAY\s+(\d+)\s+([\d\.E+-]+).*", line.upper()) 210 match = re.match(r"DECAY\s+(\d+)\s+([\d\.E+-]+).*", line.upper())
291 yield s + sep + _autostr(d) 291 yield s + sep + _autostr(d)
292 ## Blocks 292 ## Blocks
293 for bname, b in sorted(blocks.iteritems()): 293 for bname, b in sorted(blocks.iteritems()):
294 namestr = b.name 294 namestr = b.name
295 if b.q is not None: 295 if b.q is not None:
296 namestr += " Q= %e" % b.q 296 namestr += " Q= %e" % float(b.q)
297 out += "BLOCK %s\n" % namestr 297 out += "BLOCK %s\n" % namestr
298 for s in dict_hier_strs(b.entries): 298 for s in dict_hier_strs(b.entries):
299 out += sep + s + "\n" 299 out += sep + s + "\n"
300 out += "\n" 300 out += "\n"
301 ## Decays 301 ## Decays

mercurial