MCPcopy Create free account
hub / github.com/SourceCode-AI/aura / ast2json

Function ast2json

aura/analyzers/python_src_inspector.py:66–84  ·  view source on GitHub ↗

Inspired by: https://github.com/YoloSwagTeam/ast2json/blob/master/ast2json/ast2json.py

(node)

Source from the content-addressed store, hash-verified

64
65
66def ast2json(node):
67 """
68 Inspired by:
69 https://github.com/YoloSwagTeam/ast2json/blob/master/ast2json/ast2json.py
70 """
71 assert isinstance(node, ast.AST)
72 data = OrderedDict()
73 data["_type"] = node.__class__.__name__
74
75 # try:
76 # data['_doc_string'] = ast.get_docstring(node)
77 # except TypeError:
78 # pass
79
80 for attr, target in node.__dict__.items():
81 if attr.startswith("_"):
82 continue
83 data[attr] = get_value(target)
84 return data
85
86
87def get_value(attr):

Callers 2

get_valueFunction · 0.85
collectFunction · 0.85

Calls 1

get_valueFunction · 0.85

Tested by

no test coverage detected