MCPcopy
hub / github.com/pallets/jinja / iter_child_nodes

Method iter_child_nodes

src/jinja2/nodes.py:169–184  ·  view source on GitHub ↗

Iterates over all direct child nodes of the node. This iterates over all fields and yields the values of they are nodes. If the value of a field is a list all the nodes in that list are returned.

(
        self,
        exclude: t.Optional[t.Container[str]] = None,
        only: t.Optional[t.Container[str]] = None,
    )

Source from the content-addressed store, hash-verified

167 pass
168
169 def iter_child_nodes(
170 self,
171 exclude: t.Optional[t.Container[str]] = None,
172 only: t.Optional[t.Container[str]] = None,
173 ) -> t.Iterator["Node"]:
174 """Iterates over all direct child nodes of the node. This iterates
175 over all fields and yields the values of they are nodes. If the value
176 of a field is a list all the nodes in that list are returned.
177 """
178 for _, item in self.iter_fields(exclude, only):
179 if isinstance(item, list):
180 for n in item:
181 if isinstance(n, Node):
182 yield n
183 elif isinstance(item, Node):
184 yield item
185
186 def find(self, node_type: t.Type[_NodeBound]) -> t.Optional[_NodeBound]:
187 """Find the first node of a given type. If no such node exists the

Callers 8

find_allMethod · 0.95
visit_ForMethod · 0.80
generic_visitMethod · 0.80
_simple_visitMethod · 0.80
visit_CallBlockMethod · 0.80
set_ctxMethod · 0.80
set_linenoMethod · 0.80
set_environmentMethod · 0.80

Calls 1

iter_fieldsMethod · 0.95

Tested by

no test coverage detected