@@ -408,7 +408,7 @@ def update_edges(self, edges: List[GEdge], teamid: str):
408
408
409
409
def get_node_by_id (self , nodeid : str , node_type :str = None ) -> GNode :
410
410
node = self .gb .get_current_node ({'id' : nodeid }, node_type = node_type )
411
- extra_attrs = json .loads (node .attributes .pop ("extra" , "{}" ))
411
+ extra_attrs = json .loads (node .attributes .pop ("extra" , "{}" ) or "{}" )
412
412
node .attributes .update (extra_attrs )
413
413
return node
414
414
@@ -418,10 +418,10 @@ def get_graph_by_nodeid(self, nodeid: str, node_type: str, teamid: str=None, hop
418
418
# filter the node which dont match teamid
419
419
result = self .gb .get_hop_infos ({'id' : nodeid }, node_type = node_type , hop = hop )
420
420
for node in result .nodes :
421
- extra_attrs = json .loads (node .attributes .pop ("extra" , "{}" ))
421
+ extra_attrs = json .loads (node .attributes .pop ("extra" , "{}" ) or "{}" )
422
422
node .attributes .update (extra_attrs )
423
423
for edge in result .edges :
424
- extra_attrs = json .loads (edge .attributes .pop ("extra" , "{}" ))
424
+ extra_attrs = json .loads (edge .attributes .pop ("extra" , "{}" ) or "{}" )
425
425
edge .attributes .update (extra_attrs )
426
426
return result
427
427
@@ -463,18 +463,18 @@ def search_nodes_by_text(self, text: str, node_type: str = None, teamid: str = N
463
463
nodes_by_desc = self .gb .get_current_nodes ({"description" : text }, node_type = node_type )
464
464
nodes = self .gb .get_nodes_by_ids (nodeids )
465
465
for node in nodes :
466
- extra_attrs = json .loads (node .attributes .pop ("extra" , "{}" ))
466
+ extra_attrs = json .loads (node .attributes .pop ("extra" , "{}" ) or "{}" )
467
467
node .attributes .update (extra_attrs )
468
468
return nodes_by_name + nodes_by_desc + nodes
469
469
470
470
def search_rootpath_by_nodeid (self , nodeid : str , node_type : str , rootid : str ) -> Graph :
471
471
# rootid = f"{teamid}" # todo check the rootid
472
472
result = self .gb .get_hop_infos ({"id" : nodeid }, node_type = node_type , hop = 15 , reverse = True )
473
473
for node in result .nodes :
474
- extra_attrs = json .loads (node .attributes .pop ("extra" , "{}" ))
474
+ extra_attrs = json .loads (node .attributes .pop ("extra" , "{}" ) or "{}" )
475
475
node .attributes .update (extra_attrs )
476
476
for edge in result .edges :
477
- extra_attrs = json .loads (edge .attributes .pop ("extra" , "{}" ))
477
+ extra_attrs = json .loads (edge .attributes .pop ("extra" , "{}" ) or "{}" )
478
478
edge .attributes .update (extra_attrs )
479
479
480
480
# paths must be ordered from start to end
0 commit comments