From e5bb0ee5976f2f1348387ed6ed57cc43e34caa7c Mon Sep 17 00:00:00 2001 From: LV-426 Date: Sun, 9 Nov 2014 12:10:57 +0200 Subject: Topo_Diff - support omitted-argument construction --- src-py/model/graph.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src-py/model/graph.py') diff --git a/src-py/model/graph.py b/src-py/model/graph.py index 8942285d..bc642a69 100644 --- a/src-py/model/graph.py +++ b/src-py/model/graph.py @@ -54,6 +54,15 @@ class Topo_Diff(object): @staticmethod def from_dict(topo_diff_dict): + """ + construct from dict - no node/link constructor set must be provided + """ ret = Topo_Diff() - ret.__dict__ = topo_diff_dict + + # merge keys - this allows obj constructor argument ommision, + # such as when constructing from POST JSON data + for k, _ in ret.__dict__.items(): + v = topo_diff_dict.get(k) + if None != v: + ret.__dict__[k] = v return ret -- cgit v1.3.1