Esempio n. 1
0
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)
Esempio n. 2
0
def iter_variables(ast) -> Iterator[NodeInfo]:
    for stack, node in _iter_nodes_filtered(ast, accept_class="Variable"):
        yield NodeInfo(tuple(stack), node)
Esempio n. 3
0
def iter_keywords(ast) -> Iterator[NodeInfo]:
    for stack, node in _iter_nodes_filtered(ast, accept_class="Keyword"):
        yield NodeInfo(tuple(stack), node)
Esempio n. 4
0
def iter_resource_imports(ast) -> Iterator[NodeInfo]:
    for stack, node in _iter_nodes_filtered(ast, accept_class="ResourceImport"):
        yield NodeInfo(tuple(stack), node)
Esempio n. 5
0
def iter_library_imports(ast) -> Iterator[NodeInfo[ILibraryImportNode]]:
    for stack, node in _iter_nodes_filtered(ast, accept_class="LibraryImport"):
        yield NodeInfo(tuple(stack), node)
Esempio n. 6
0
def iter_all_nodes(ast, recursive=True) -> Iterator[NodeInfo]:
    for stack, node in _iter_nodes(ast, recursive=recursive):
        yield NodeInfo(tuple(stack), node)
Esempio n. 7
0
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)
Esempio n. 8
0
def iter_tests(ast) -> Iterator[NodeInfo]:
    for stack, node in _iter_nodes_filtered(ast, accept_class="TestCase"):
        yield NodeInfo(tuple(stack), node)