Commit 44d8e30a authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

simplify _coerce_props()

parent fd6e2563
......@@ -55,15 +55,29 @@ def get_entries(names=None):
return {entry.name : entry for entry in entries}
def _coerce_props(g, vforce={}, eforce={}):
def coerce_numeric(p):
if p.value_type() == "string":
try:
p = p.copy("int")
except ValueError:
try:
p = p.copy("double")
except:
pass
return p
for k in g.vp:
if k in vforce:
g.vp[k] = g.vp[k].copy(vforce[k])
else:
g.vp[k] = coerce_numeric(g.vp[k])
g.vp[k] = g.vp[k].coerce_type()
for k in g.ep:
if k in eforce:
g.ep[k] = g.ep[k].copy(eforce[k])
else:
g.ep[k] = coerce_numeric(g.ep[k])
g.ep[k] = g.ep[k].coerce_type()
def coerce_props(vforce={}, eforce={}):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment