MCPcopy Create free account
hub / github.com/ParzivalHack/PySpector / _ast_node

Function _ast_node

tests/unit/test_ai_rules.py:38–51  ·  view source on GitHub ↗
(node: ast.AST)

Source from the content-addressed store, hash-verified

36
37
38def _ast_node(node: ast.AST) -> dict:
39 children = {}
40 fields = {}
41 for field, value in ast.iter_fields(node):
42 if isinstance(value, list):
43 if value and all(isinstance(item, ast.AST) for item in value):
44 children[field] = [_ast_node(item) for item in value]
45 else:
46 fields[field] = str(value) if value else []
47 elif isinstance(value, ast.AST):
48 children[field] = [_ast_node(value)]
49 else:
50 fields[field] = value if isinstance(value, (int, float, str, bool)) or value is None else str(value)
51 return {"node_type": node.__class__.__name__, "children": children, "fields": fields}
52
53
54def _has_property(node: dict, path: list[str], expected: str) -> bool:

Callers 1

_matches_ai206Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected