Given a tree element, recursively separate that AST into lists of ASTs for the subgroups, nodes, and body. This is an intermediate step to allow for cleaner processing downstream :param tree ast: :returns: tuple of group, node, and body trees. These are proc
(tree)
| 228 | |
| 229 | @staticmethod |
| 230 | def separate_namespaces(tree): |
| 231 | """ |
| 232 | Given a tree element, recursively separate that AST into lists of ASTs for the |
| 233 | subgroups, nodes, and body. This is an intermediate step to allow for |
| 234 | cleaner processing downstream |
| 235 | |
| 236 | :param tree ast: |
| 237 | :returns: tuple of group, node, and body trees. These are processed |
| 238 | downstream into real Groups and Nodes. |
| 239 | :rtype: (list[ast], list[ast], list[ast]) |
| 240 | """ |
| 241 | groups = [] |
| 242 | nodes = [] |
| 243 | body = [] |
| 244 | for el in as_lines(tree): |
| 245 | if el[0] in ('def', 'defs'): |
| 246 | nodes.append(el) |
| 247 | elif el[0] in ('class', 'module'): |
| 248 | groups.append(el) |
| 249 | else: |
| 250 | body.append(el) |
| 251 | return groups, nodes, body |
| 252 | |
| 253 | @staticmethod |
| 254 | def make_nodes(tree, parent): |
no test coverage detected