betty.machine_name module

Machine names.

final exception betty.machine_name.InvalidMachineName

Bases: HumanFacingException, ValueError

Raised when something is not a valid machine name.

__init__(value: str, /)
final class betty.machine_name.MachineName

Bases: Portable[str], str, Data

A machine name.

A machine name is a string that meets these criteria: - At least 1 character long. - At most 250 characters long. - Lowercase letters, numbers, and non-consecutive hyphens (-).

__init__(machine_name: str | None = None, /)
static __new__(cls, machine_name: str | None = None, /)
dump() str

Dump the instance to portable data.

Raises:

betty.portable.error.NotPortable – Raised if any part of the data is not portable.

classmethod load(portable: PortableData, /) Self

Create a new instance from portable data.

Raises:

betty.exception.HumanFacingException – Raised if the portable data is invalid.

classmethod machinify(source: str, /) Self | None

Attempt to convert a source string into a valid machine name.

property persistent: bool

Whether this machine name is persistent, and will exist beyond the current Betty process.

classmethod resolve(machine_name: ResolvableMachineName) MachineName

Resolve a value to a machine name.