|
|
|
@ -62,7 +62,7 @@ class Marker(StrictUndefined, Tripwire):
|
|
|
|
|
|
|
|
|
|
|
|
__slots__ = ('_marker_template_source',)
|
|
|
|
__slots__ = ('_marker_template_source',)
|
|
|
|
|
|
|
|
|
|
|
|
concrete_subclasses: t.ClassVar[set[type[Marker]]] = set()
|
|
|
|
_concrete_subclasses: t.ClassVar[set[type[Marker]]] = set()
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
self,
|
|
|
|
@ -136,7 +136,7 @@ class Marker(StrictUndefined, Tripwire):
|
|
|
|
def __init_subclass__(cls, **kwargs) -> None:
|
|
|
|
def __init_subclass__(cls, **kwargs) -> None:
|
|
|
|
if not inspect.isabstract(cls):
|
|
|
|
if not inspect.isabstract(cls):
|
|
|
|
_untaggable_types.add(cls)
|
|
|
|
_untaggable_types.add(cls)
|
|
|
|
cls.concrete_subclasses.add(cls)
|
|
|
|
cls._concrete_subclasses.add(cls)
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
@classmethod
|
|
|
|
def _init_class(cls):
|
|
|
|
def _init_class(cls):
|
|
|
|
@ -277,16 +277,12 @@ class VaultExceptionMarker(ExceptionMarker):
|
|
|
|
|
|
|
|
|
|
|
|
def get_first_marker_arg(args: c.Sequence, kwargs: dict[str, t.Any]) -> Marker | None:
|
|
|
|
def get_first_marker_arg(args: c.Sequence, kwargs: dict[str, t.Any]) -> Marker | None:
|
|
|
|
"""Utility method to inspect plugin args and return the first `Marker` encountered, otherwise `None`."""
|
|
|
|
"""Utility method to inspect plugin args and return the first `Marker` encountered, otherwise `None`."""
|
|
|
|
# DTFIX0: this may or may not need to be public API, move back to utils or once usage is wrapped in a decorator?
|
|
|
|
# CAUTION: This function is exposed in public API as ansible.template.get_first_marker_arg.
|
|
|
|
for arg in iter_marker_args(args, kwargs):
|
|
|
|
return next(iter_marker_args(args, kwargs), None)
|
|
|
|
return arg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def iter_marker_args(args: c.Sequence, kwargs: dict[str, t.Any]) -> t.Generator[Marker]:
|
|
|
|
def iter_marker_args(args: c.Sequence, kwargs: dict[str, t.Any]) -> t.Generator[Marker]:
|
|
|
|
"""Utility method to iterate plugin args and yield any `Marker` encountered."""
|
|
|
|
"""Utility method to iterate plugin args and yield any `Marker` encountered."""
|
|
|
|
# DTFIX0: this may or may not need to be public API, move back to utils or once usage is wrapped in a decorator?
|
|
|
|
|
|
|
|
for arg in itertools.chain(args, kwargs.values()):
|
|
|
|
for arg in itertools.chain(args, kwargs.values()):
|
|
|
|
if isinstance(arg, Marker):
|
|
|
|
if isinstance(arg, Marker):
|
|
|
|
yield arg
|
|
|
|
yield arg
|
|
|
|
@ -301,7 +297,7 @@ class JinjaCallContext(NotifiableAccessContextBase):
|
|
|
|
_mask = True
|
|
|
|
_mask = True
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, accept_lazy_markers: bool) -> None:
|
|
|
|
def __init__(self, accept_lazy_markers: bool) -> None:
|
|
|
|
self._type_interest = frozenset() if accept_lazy_markers else frozenset(Marker.concrete_subclasses)
|
|
|
|
self._type_interest = frozenset() if accept_lazy_markers else frozenset(Marker._concrete_subclasses)
|
|
|
|
|
|
|
|
|
|
|
|
def _notify(self, o: Marker) -> t.NoReturn:
|
|
|
|
def _notify(self, o: Marker) -> t.NoReturn:
|
|
|
|
o.trip()
|
|
|
|
o.trip()
|
|
|
|
|