def iter_nodes( ast, accept_class: Union[Tuple[str, ...], str], recursive=True ) -> Iterator[NodeInfo]: if not isinstance(accept_class, (list, tuple, set)): accept_class = (accept_class,) for stack, node in _iter_nodes(ast, recursive=recursive): if node.__class__.__name__ in accept_class: yield NodeInfo(tuple(stack), node)
def iter_variables(ast) -> Iterator[NodeInfo]: for stack, node in _iter_nodes_filtered(ast, accept_class="Variable"): yield NodeInfo(tuple(stack), node)
def iter_keywords(ast) -> Iterator[NodeInfo]: for stack, node in _iter_nodes_filtered(ast, accept_class="Keyword"): yield NodeInfo(tuple(stack), node)
def iter_resource_imports(ast) -> Iterator[NodeInfo]: for stack, node in _iter_nodes_filtered(ast, accept_class="ResourceImport"): yield NodeInfo(tuple(stack), node)
def iter_library_imports(ast) -> Iterator[NodeInfo[ILibraryImportNode]]: for stack, node in _iter_nodes_filtered(ast, accept_class="LibraryImport"): yield NodeInfo(tuple(stack), node)
def iter_all_nodes(ast, recursive=True) -> Iterator[NodeInfo]: for stack, node in _iter_nodes(ast, recursive=recursive): yield NodeInfo(tuple(stack), node)
def iter_test_case_sections(ast) -> Iterator[NodeInfo]: # Sections are top-level, so, we don't need to do it recursively. for stack, node in _iter_nodes_filtered(ast, accept_class="TestCaseSection", recursive=False): yield NodeInfo(tuple(stack), node)
def iter_tests(ast) -> Iterator[NodeInfo]: for stack, node in _iter_nodes_filtered(ast, accept_class="TestCase"): yield NodeInfo(tuple(stack), node)