(node)
| 73 | |
| 74 | |
| 75 | def ast2json(node): |
| 76 | assert isinstance(node, AST) |
| 77 | to_return = dict() |
| 78 | to_return["_type"] = node.__class__.__name__ |
| 79 | for attr in dir(node): |
| 80 | if attr.startswith("_") or attr == "n" or attr == "s": |
| 81 | continue |
| 82 | to_return[attr] = get_value(getattr(node, attr)) |
| 83 | to_return.pop("lineno", None) |
| 84 | to_return.pop("end_lineno", None) |
| 85 | to_return.pop("col_offset", None) |
| 86 | to_return.pop("end_col_offset", None) |
| 87 | return to_return |
| 88 | |
| 89 | |
| 90 | def get_value(attr_value): |
no test coverage detected