(node, nodes_dict)
| 434 | |
| 435 | |
| 436 | def parse_node(node, nodes_dict): |
| 437 | eid = _get_eid(node) |
| 438 | if not eid or eid in nodes_dict: |
| 439 | return |
| 440 | |
| 441 | labels = [] |
| 442 | if isinstance(node, dict): |
| 443 | meta_label = _meta(node, 'label') |
| 444 | if meta_label is not None: |
| 445 | labels = [meta_label] |
| 446 | elif 'label' in node: |
| 447 | labels = [node['label']] |
| 448 | else: |
| 449 | for label_attr in ['_labels', 'labels']: |
| 450 | if hasattr(node, label_attr): |
| 451 | attr_val = getattr(node, label_attr) |
| 452 | if attr_val: |
| 453 | labels = list(attr_val) |
| 454 | break |
| 455 | |
| 456 | props = {} |
| 457 | if isinstance(node, dict): |
| 458 | props = {k: v for k, v in node.items() if not k.startswith('_')} |
| 459 | else: |
| 460 | for prop_attr in ['properties', '_properties']: |
| 461 | if hasattr(node, prop_attr): |
| 462 | attr_val = getattr(node, prop_attr) |
| 463 | if attr_val: |
| 464 | props = dict(attr_val) |
| 465 | break |
| 466 | if not props and hasattr(node, 'items'): |
| 467 | try: |
| 468 | props = dict(node.items()) |
| 469 | except: pass |
| 470 | |
| 471 | display_name = str(props.get('name', props.get('label', props.get('path', 'Unknown')))) |
| 472 | |
| 473 | nodes_dict[eid] = { |
| 474 | "id": eid, |
| 475 | "name": display_name, |
| 476 | "label": display_name, |
| 477 | "type": str(labels[0]).capitalize() if labels else "Other", |
| 478 | "file": str(props.get('path', props.get('file', ''))), |
| 479 | "val": 4 if (labels and labels[0] in ['Repository', 'Class', 'Interface', 'Trait']) else 2, |
| 480 | "properties": props |
| 481 | } |
| 482 | |
| 483 | |
| 484 | def parse_rel(rel, edges): |
no test coverage detected