File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -197,9 +197,11 @@ def _parse_char_metrics(fh):
197197 line = line .rstrip ()
198198 if line .startswith (b'EndCharMetrics' ):
199199 return ascii_d , name_d
200- vals = filter (lambda s : s != b'' , line .split (b';' )) # Split into a list of metrics
201- vals = dict (map (lambda s : tuple (s .strip ().split (b' ' , 1 )), vals )) # Split out the metric identifier and use as key for a dictionary
202- if b'C' not in vals .keys () or b'WX' not in vals .keys () or b'N' not in vals .keys () or b'B' not in vals .keys () :
200+ # Split metric line into dictonary keyed by the metric identifiers
201+ vals = filter (lambda s : s != b'' , line .split (b';' ))
202+ vals = dict (map (lambda s : tuple (s .strip ().split (b' ' , 1 )), vals ))
203+ # check for the required metrics
204+ if any ([id not in vals .keys () for id in (b'C' , b'WX' , b'N' , b'B' )]) :
203205 raise RuntimeError ('Bad char metrics line: %s' % line )
204206 num = _to_int (vals [b'C' ])
205207 wx = _to_float (vals [b'WX' ])
You can’t perform that action at this time.
0 commit comments