rechu.inventory package

Submodules

rechu.inventory.base module

Bag of files containing multiple grouped models that share common properties.

class rechu.inventory.base.Inventory[source]

Bases: Mapping[Path, Sequence[T]]

An inventory of a type of model grouped by one or more characteristics, which are concretized in file names.

get_writers() Iterator[Writer[T]][source]

Obtain writers for each inventory file.

merge_update(other: Inventory[T], update: bool = True, only_new: bool = False) Inventory[T][source]

Find groups with models that are added or updated in the other inventory compared to the current inventory. The returned inventory contains the new, existing and merged models grouped by path; only paths with changes are included. The products in the current inventory are updated as well. If update is enabled, then new models are added to and changed models updated in the current inventory; this is the default. If update is disabled, then only the updated models are provided in the return value and the current object also remains immutable. If only_new is enabled, then models that existed but had changes are not considered, just like unchanged models; only_new inherently disables update.

classmethod read() Inventory[T][source]

Create an inventory based on models stored in files.

classmethod select(session: Session, selectors: list[dict[str, str | None]] | None = None) Inventory[T][source]

Create an inventory based on models stored in the database.

classmethod spread(models: Iterable[T]) Inventory[T][source]

Create an inventory based on provided models by assigning them to groups that each belongs to.

write() None[source]

Write an inventory to files.

rechu.inventory.products module

Products inventory.

class rechu.inventory.products.Products(mapping=None, /, parts: tuple[str, ...] | None = None)[source]

Bases: dict, Inventory[Product]

Inventory of products grouped by their identifying fields.

static get_parts(settings: Settings) tuple[str, str, tuple[str, ...], Pattern[str]][source]

Retrieve various formatting, selecting and matching parts for inventory filenames of products.

get_writers() Iterator[ProductsWriter][source]

Obtain writers for each inventory file.

merge_update(other: Inventory[Product], update: bool = True, only_new: bool = False) Inventory[Product][source]

Find groups with models that are added or updated in the other inventory compared to the current inventory. The returned inventory contains the new, existing and merged models grouped by path; only paths with changes are included. The products in the current inventory are updated as well. If update is enabled, then new models are added to and changed models updated in the current inventory; this is the default. If update is disabled, then only the updated models are provided in the return value and the current object also remains immutable. If only_new is enabled, then models that existed but had changes are not considered, just like unchanged models; only_new inherently disables update.

classmethod read() Inventory[Product][source]

Create an inventory based on models stored in files.

classmethod select(session: Session, selectors: list[dict[str, str | None]] | None = None) Inventory[Product][source]

Create an inventory based on models stored in the database.

classmethod spread(models: Iterable[Product]) Inventory[Product][source]

Create an inventory based on provided models by assigning them to groups that each belongs to.

Module contents

Submodule for inventory of grouped models.