file_loader_factory

glotaran.project.dataclass_helpers.file_loader_factory(targetClass: type[FileLoadable], *, is_wrapper_class: bool = False) Callable[[FileLoadable | str | Path], FileLoadable][source]

Create file_loader functions to load targetClass from file.

Parameters:
  • targetClass (type[FileLoadable]) – Class the loader function should return an instance of.

  • is_wrapper_class (bool) – Whether or not targetClass is a wrapper class, so the isinstance check will be ignored and instead the responsibility for supported types lies at the implementation of the loader.

Returns:

file_loader – Function to load FileLoadable from source file or return instance if already loaded.

Return type:

Callable[[FileLoadable | str | Path], FileLoadable]