(names)
Walks over all the names imported in a dotted_as_names node.
Walks over all the names imported in a dotted_as_names node.
Walks over all the names imported in a dotted_as_names node .
def traverse_imports(names):
    """
    Walks over all the names imported in a dotted_as_names node.
    """
    pending = [names]
    while pending:
        node = pending.pop()
        if node.type == token.NAME:
            yield node.value
        elif node.type == syms.dotted_name:
            yield "".join([ch.value for ch in node.children])
        elif node.type == syms.dotted_as_name:
            pending.append(node.children[0])
        elif node.type == syms.dotted_as_names:
            pending.extend(node.children[::-2])
        else:
            raise AssertionError("unknown node type")
def traverse_imports ( names ) : pending = [ names ] while pending : node = pending . pop ( ) if node . type == token . NAME : yield node . value elif node . type == syms . dotted_name : yield "" . join ( [ ch . value for ch in node . children ] ) elif node . type == syms . dotted_as_name : pending . append ( node . children [ 0 ] ) elif node . type == syms . dotted_as_names : pending . extend ( node . children [ : : - 2 ] ) else : raise AssertionError ( "unknown node type" )