ProjectRegistry

class glotaran.project.project_registry.ProjectRegistry(directory: Path, file_suffix: str | list[str], loader: Callable)[source]

Bases: object

A registry base class.

Initialize a registry.

Parameters
  • directory (Path) – The registry directory.

  • file_suffix (str | list[str]) – The suffixes of item files.

  • loader (Callable) – A loader for the registry items.

Attributes Summary

directory

Get the registry directory.

empty

Whether the registry is empty.

items

Get the items of the registry.

Methods Summary

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

bool

is_item(path: pathlib.Path) bool[source]

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: dict[str, Path]

Get the items of the registry.

Returns

The items of the registry.

Return type

dict[str, Path]

load_item(name: str) Any[source]

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[source]

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