ProjectDataRegistry
- class glotaran.project.project_data_registry.ProjectDataRegistry(directory: Path)[source]
Bases:
ProjectRegistry
A registry for data.
Initialize a data 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
Import a dataset.
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: 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:
- import_data(dataset: str | Path | Dataset | DataArray, dataset_name: str | None = None, allow_overwrite: bool = False, ignore_existing: bool = False)[source]
Import a dataset.
- Parameters:
dataset (str | Path | xr.Dataset | xr.DataArray) – Dataset instance or path to a dataset.
dataset_name (str | None) – The name of the dataset (needs to be provided when dataset is an xarray instance). Defaults to None.
allow_overwrite (bool) – Whether to overwrite an existing dataset.
ignore_existing (bool) – Whether to ignore import if the dataset already exists.
- Raises:
ValueError – When importing from xarray object and not providing a name.
- 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:
- property items: ItemMapping
Get the items of the registry.
- Returns:
The items of the registry.
- 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) MarkdownStr
Format the registry items as a markdown text.