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

Method iter_fields

src/jinja2/nodes.py:147–167  ·  view source on GitHub ↗

This method iterates over all fields that are defined and yields ``(key, value)`` tuples. Per default all fields are returned, but it's possible to limit that to some fields by providing the `only` parameter or to exclude some using the `exclude` parameter. Both sho

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

Source from the content-addressed store, hash-verified

145 raise TypeError(f"unknown attribute {next(iter(attributes))!r}")
146
147 def iter_fields(
148 self,
149 exclude: t.Optional[t.Container[str]] = None,
150 only: t.Optional[t.Container[str]] = None,
151 ) -> t.Iterator[t.Tuple[str, t.Any]]:
152 """This method iterates over all fields that are defined and yields
153 ``(key, value)`` tuples. Per default all fields are returned, but
154 it's possible to limit that to some fields by providing the `only`
155 parameter or to exclude some using the `exclude` parameter. Both
156 should be sets or tuples of field names.
157 """
158 for name in self.fields:
159 if (
160 (exclude is None and only is None)
161 or (exclude is not None and name not in exclude)
162 or (only is not None and name in only)
163 ):
164 try:
165 yield name, getattr(self, name)
166 except AttributeError:
167 pass
168
169 def iter_child_nodes(
170 self,

Callers 3

iter_child_nodesMethod · 0.95
__eq__Method · 0.95
generic_visitMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected