Skip to content

ChoiceLoader

Base classes

Name Children Inherits
LoaderMixin
jinjarope.loaders
Loader mixin which allows to OR loaders into a choice loader.
ChoiceLoader
jinja2.loaders
This loader works like the `PrefixLoader` just that no prefix is

⋔ Inheritance diagram

graph TD
  97041655405984["loaders.ChoiceLoader"]
  97041656291584["loaders.LoaderMixin"]
  128674497047040["builtins.object"]
  97041654850560["loaders.ChoiceLoader"]
  97041655470432["loaders.BaseLoader"]
  97041656291584 --> 97041655405984
  128674497047040 --> 97041656291584
  97041654850560 --> 97041655405984
  97041655470432 --> 97041654850560
  128674497047040 --> 97041655470432

🛈 DocStrings

Bases: LoaderMixin, ChoiceLoader

A loader which combines multiple other loaders.

Source code in src/jinjarope/loaders.py
class ChoiceLoader(LoaderMixin, jinja2.ChoiceLoader):
    """A loader which combines multiple other loaders."""

    ID = "choice"

    def __repr__(self) -> str:
        return utils.get_repr(self, loaders=self.loaders)

    def __bool__(self) -> bool:
        return len(self.loaders) > 0

    def __eq__(self, other: object) -> bool:
        if not isinstance(other, ChoiceLoader):
            return NotImplemented
        return self.loaders == other.loaders

    def __hash__(self) -> int:
        return hash(tuple(self.loaders))

    def __iter__(self) -> Iterator[jinja2.BaseLoader]:
        return iter(self.loaders)

:fa-brands-github: Show source on GitHub