Skip to content

Alteration¤

Alteration dataclass ¤

Alteration(date: date, details: str, performed_by: str)

Represents the alteration element in an equipment register.

Parameters:

Name Type Description Default
date date

The date that the alteration was performed.

required
details str

The details of the alteration.

required
performed_by str

The person or company that performed the alteration.

required

date instance-attribute ¤

date: date

The date that the alteration was performed.

details instance-attribute ¤

details: str

The details of the alteration.

performed_by instance-attribute ¤

performed_by: str

The person or company that performed the alteration.

from_xml classmethod ¤

from_xml(element: Element[str]) -> Alteration

Convert an XML element into an Alteration instance.

Parameters:

Name Type Description Default
element Element[str]

An alteration XML element from an equipment register.

required

Returns:

Type Description
Alteration

The Alteration instance.

Source code in src/msl/equipment/schema.py
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
@classmethod
def from_xml(cls, element: Element[str]) -> Alteration:
    """Convert an XML element into an [Alteration][msl.equipment.schema.Alteration] instance.

    Args:
        element: An [alteration][type_alteration] XML element from an equipment register.

    Returns:
        The [Alteration][msl.equipment.schema.Alteration] instance.
    """
    return cls(
        date=_date.fromisoformat(element.attrib["date"]),
        details=element.text or "",
        performed_by=element.attrib["performedBy"],
    )

to_xml ¤

to_xml() -> Element[str]

Convert the Alteration class into an XML element.

Returns:

Type Description
Element[str]

The Alteration as an XML element.

Source code in src/msl/equipment/schema.py
223
224
225
226
227
228
229
230
231
def to_xml(self) -> Element[str]:
    """Convert the [Alteration][msl.equipment.schema.Alteration] class into an XML element.

    Returns:
        The [Alteration][msl.equipment.schema.Alteration] as an XML element.
    """
    e = Element("alteration", attrib={"date": self.date.isoformat(), "performedBy": self.performed_by})
    e.text = self.details
    return e