betty.model.collections module - Betty documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.model.collections module

Entity collections.

class betty.model.collections.EntityCollection

  Bases: `Generic`[`_TargetT`], `ABC`

  Provide a collection of entities.

  __init__()
  abstract add(*entities: _TargetT & Entity) → None

    Add the given entities.

  abstract clear() → None

    Clear all entities from the collection.

  abstract remove(*entities: _TargetT & Entity) → None

    Remove the given entities.

  replace(*entities: _TargetT & Entity) → None

    Replace all entities with the given ones.

  property view: Sequence[_TargetT & Entity]

    A view of the entities at the time of calling.

class betty.model.collections.MultipleTypesEntityCollection

  Bases: `Generic`[`_TargetT`], `EntityCollection`[`_TargetT`]

  Collect entities of multiple types.

  __init__()
  add(*entities: _TargetT & Entity) → None

    Add the given entities.

  clear() → None

    Clear all entities from the collection.

  remove(*entities: _TargetT & Entity) → None

    Remove the given entities.

class betty.model.collections.SingleTypeEntityCollection

  Bases: `Generic`[`_TargetT`], `EntityCollection`[`_TargetT`]

  Collect entities of a single type.

  __init__(target_type: type[_TargetT])
  add(*entities: _TargetT & Entity) → None

    Add the given entities.

  clear() → None

    Clear all entities from the collection.

  remove(*entities: _TargetT & Entity) → None

    Remove the given entities.

betty.model.collections.record_added(entities: EntityCollection[_EntityT]) → Iterator[MultipleTypesEntityCollection[_EntityT]]

  Record all entities that are added to a collection.