ProjectModelRegistry
- class glotaran.project.project_model_registry.ProjectModelRegistry(directory: pathlib.Path)[source]
Bases:
glotaran.project.project_registry.ProjectRegistry
A registry for models.
Initialize a model registry.
- Parameters
directory (Path) – The registry directory.
Attributes Summary
Get the registry directory.
Whether the registry is empty.
Get the items of the registry.
Methods Summary
Generate a model.
Check if the path contains an registry item.
Load an registry item by it's name.
Format the registry items as a markdown text.
Methods Documentation
- property directory: pathlib.Path
Get the registry directory.
- Returns
The registry directory.
- Return type
Path
- property empty: bool
Whether the registry is empty.
- Returns
Whether the registry is empty.
- Return type
- generate_model(name: str, generator_name: str, generator_arguments: glotaran.project.generators.generator.GeneratorArguments, *, allow_overwrite: bool = False, ignore_existing: bool = False)[source]
Generate a model.
- Parameters
name (str) – The name of the model.
generator_name (str) – The generator for the model.
generator_arguments (GeneratorArguments) – Arguments for the generator.
allow_overwrite (bool) – Whether to overwrite an existing model.
ignore_existing (bool) – Whether to ignore generation of a model file if it already exists.
- Raises
FileExistsError – Raised if model is already existing and allow_overwrite=False.
- is_item(path: pathlib.Path) bool
Check if the path contains an registry item.
- Parameters
path (Path) – The path to check.
- Returns
Whether the path contains an item.
- Return type
- load_item(name: str) Any
Load an registry item by it’s name.
- Parameters
name (str) – The item name.
- Returns
The loaded item.
- Return type
Any
- Raises
ValueError – Raise if the item does not exist.
- markdown(join_indentation: int = 0) glotaran.utils.ipython.MarkdownStr
Format the registry items as a markdown text.