MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _ref_address

Function _ref_address

graphify/extract.py:15809–15840  ·  view source on GitHub ↗
(expr)

Source from the content-addressed store, hash-verified

15807 return btype, labels
15808
15809 def _ref_address(expr):
15810 head = _read(expr)
15811 parent = expr.parent
15812 attrs: list[str] = []
15813 if parent is not None:
15814 seen_self = False
15815 for c in parent.children:
15816 if c.id == expr.id:
15817 seen_self = True
15818 continue
15819 if seen_self and c.type == "get_attr":
15820 name = None
15821 for gc in c.children:
15822 if gc.type == "identifier":
15823 name = _read(gc)
15824 break
15825 if name is None:
15826 break
15827 attrs.append(name)
15828 elif seen_self and c.type not in ("get_attr",):
15829 break
15830 if head in _TF_META_HEADS or not head:
15831 return None
15832 if head == "var":
15833 return f"var.{attrs[0]}" if attrs else None
15834 if head == "local":
15835 return f"local.{attrs[0]}" if attrs else None
15836 if head == "module":
15837 return f"module.{attrs[0]}" if attrs else None
15838 if head == "data":
15839 return f"data.{attrs[0]}.{attrs[1]}" if len(attrs) >= 2 else None
15840 return f"{head}.{attrs[0]}" if attrs else None
15841
15842 def _collect_refs(node, owner_nid: str, relation: str) -> None:
15843 rel = relation

Callers 1

_collect_refsFunction · 0.85

Calls 1

_readFunction · 0.85

Tested by

no test coverage detected