Recursively traverse the RAW AST JSON tree and convert them into ASTNodeIdentifier tree :param node: :return:
(node)
| 90 | |
| 91 | |
| 92 | def extract_identifier(node): |
| 93 | """ |
| 94 | Recursively traverse the RAW AST JSON tree and convert them into ASTNodeIdentifier tree |
| 95 | |
| 96 | :param node: |
| 97 | :return: |
| 98 | """ |
| 99 | # We want to only process raw ast node which must be dict types and have a `_type` key |
| 100 | if isinstance(node, dict): |
| 101 | t = node.get('_type') |
| 102 | if t in AST_NODE_TYPES: # Process the AST node via a specific node converter |
| 103 | return AST_NODE_TYPES[t](node) |
| 104 | elif t is not None: # Unknown/unsupported node, output it as misc without further recursion |
| 105 | return ASTNodeIdentifier(label=t, node_type='misc') |
| 106 | |
| 107 | |
| 108 | #---[ Functions to convert raw ast dict nodes into ASTNodeIdentifier based on their type ]--- |
no test coverage detected