ProjectParameterRegistry

class glotaran.project.project_parameter_registry.ProjectParameterRegistry(directory: Path)[source]

Bases: ProjectRegistry

A registry for parameters.

Initialize a parameter registry.

Parameters:

directory (Path) – The registry directory.

Attributes Summary

directory

Get the registry directory.

empty

Whether the registry is empty.

items

Get the items of the registry.

Methods Summary

generate_parameters

Generate parameters for a model.

is_item

Check if the path contains an registry item.

load_item

Load an registry item by it's name.

markdown

Format the registry items as a markdown text.

Methods Documentation

property directory: 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:

bool

generate_parameters(model: Model, name: str | None, *, format_name: Literal['yml', 'yaml', 'csv'] = 'csv', allow_overwrite: bool = False, ignore_existing: bool = False)[source]

Generate parameters for a model.

Parameters:
  • model (Model) – The model.

  • name (str | None) – The name of the parameters.

  • format_name (Literal["yml", "yaml", "csv"]) – The parameter format.

  • allow_overwrite (bool) – Whether to overwrite existing parameters.

  • ignore_existing (bool) – Whether to ignore generation of a parameter file if it already exists.

Raises:

FileExistsError – Raised if parameters is already existing and allow_overwrite=False.

is_item(path: 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:

bool

property items: ItemMapping

Get the items of the registry.

Returns:

The items of the registry.

Return type:

ItemMapping

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) MarkdownStr

Format the registry items as a markdown text.

Parameters:

join_indentation (int) – Number of whitespaces to indent when joining the parts. This is intended to be used with dedent when used in an indented f-string. Defaults to 0.

Returns:

MarkdownStr – The markdown string.

Return type:

str