betty.config.collections.sequence 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.config.collections.sequence module

Define and provide sequences of `betty.config.Configuration` instances.

class betty.config.collections.sequence.ConfigurationSequence

  Bases: `ConfigurationCollection`[`int`, `_ConfigurationT`], `Generic`[`_ConfigurationT`]

  A sequence of configuration values.

  To test your own subclasses, use `betty.test_utils.config.collections.sequence.ConfigurationSequenceTestBase`.

  __init__(configurations: Iterable[_ConfigurationT] | None = None)
  append(*configurations: _ConfigurationT) → None

    Append the given values to the end of the sequence.

  dump() → bool | int | float | str | None | MutableSequence[bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]] | MutableMapping[str, bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]] | type[Void]

    Dump this instance to a portable format.

  insert(index: int, *configurations: _ConfigurationT) → None

    Insert the given values at the given index.

  keys() → Iterator[int]

    Get all keys in this collection.

  load(dump: bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]) → None

    Load dumped configuration.

    Raises:

      betty.assertion.error.AssertionFailed – Raised if the dump contains invalid configuration.

  prepend(*configurations: _ConfigurationT) → None

    Prepend the given values to the beginning of the sequence.

  replace(*configurations: _ConfigurationT) → None

    Replace any existing values with the given ones.

  to_index(configuration_key: int) → int

    Get the index for the given key.

  to_key(index: int) → int

    Get the key for the item at the given index.

  update(other: Self) → None

    Update this configuration with the values from `other`.

  values() → Iterator[_ConfigurationT]

    Get all values in this collection.