Skip to content

PerformanceCheck¤

PerformanceCheck dataclass ¤

PerformanceCheck(
    completed_date: date,
    competency: Competency,
    entered_by: str = "",
    checked_by: str = "",
    checked_date: date | None = None,
    conditions: Conditions = Conditions(),
    cvd_equations: tuple[CVDEquation, ...] = (),
    deserialisers: tuple[Deserialised, ...] = (),
    equations: tuple[Equation, ...] = (),
    files: tuple[File, ...] = (),
    tables: tuple[Table, ...] = (),
)

Represents the performanceCheck element in an equipment register.

Parameters:

Name Type Description Default
completed_date date

The date that the performance check was completed.

required
competency Competency

The competent people who accomplished the performance check and the technical procedure that was executed.

required
entered_by str

The name of the person who initially entered the <performanceCheck> element in the register.

''
checked_by str

The name of the person who checked the information in the <performanceCheck> element.

''
checked_date date | None

The date that the information in the <performanceCheck> element was last checked.

None
conditions Conditions

The conditions under which the performance check is valid.

Conditions()
cvd_equations tuple[CVDEquation, ...]

Performance-check data is expressed as Callendar-Van Dusen equations.

()
deserialisers tuple[Deserialised, ...]

Performance-check data is stored in serialised formats and deserialised.

()
equations tuple[Equation, ...]

Performance-check data is expressed as equations.

()
files tuple[File, ...]

Performance-check data is stored in other files (not in the equipment register).

()
tables tuple[Table, ...]

Performance-check data is stored as Comma Separated Values (CSV) tables.

()

checked_by class-attribute instance-attribute ¤

checked_by: str = ''

The name of the person who checked the information in the <performanceCheck> element.

checked_date class-attribute instance-attribute ¤

checked_date: date | None = None

The date that the information in the <performanceCheck> element was last checked.

competency instance-attribute ¤

competency: Competency

The competent people who accomplished the performance check and the technical procedure that was executed.

completed_date instance-attribute ¤

completed_date: date

The date that the performance check was completed.

conditions class-attribute instance-attribute ¤

conditions: Conditions = field(default_factory=Conditions)

The conditions under which the performance check is valid.

cvd_equation property ¤

cvd_equation: CVDEquation

Returns the first item in the cvd_equations tuple.

Raises IndexError if the performance check does not contain Callendar-Van Dusen equations.

cvd_equations class-attribute instance-attribute ¤

cvd_equations: tuple[CVDEquation, ...] = ()

Performance-check data is expressed as Callendar-Van Dusen equations.

deserialised property ¤

deserialised: Deserialised

Returns the first item in the deserialisers tuple.

Raises IndexError if the performance check does not contain serialised data.

deserialisers class-attribute instance-attribute ¤

deserialisers: tuple[Deserialised, ...] = ()

Performance-check data is stored in serialised formats and deserialised.

entered_by class-attribute instance-attribute ¤

entered_by: str = ''

The name of the person who initially entered the <performanceCheck> element in the register.

equation property ¤

equation: Equation

Returns the first item in the equations tuple.

Raises IndexError if the performance check does not contain equations.

equations class-attribute instance-attribute ¤

equations: tuple[Equation, ...] = ()

Performance-check data is expressed as equations.

file property ¤

file: File

Returns the first item in the files tuple.

Raises IndexError if the performance check does not contain files.

files class-attribute instance-attribute ¤

files: tuple[File, ...] = ()

Performance-check data is stored in other files (not in the equipment register).

table property ¤

table: Table

Returns the first item in the tables tuple.

Raises IndexError if the performance check does not contain tables.

tables class-attribute instance-attribute ¤

tables: tuple[Table, ...] = ()

Performance-check data is stored as Comma Separated Values (CSV) tables.

from_xml classmethod ¤

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

Convert an XML element into a PerformanceCheck instance.

Parameters:

Name Type Description Default
element Element[str]

A performanceCheck XML element from an equipment register.

required

Returns:

Type Description
PerformanceCheck

The PerformanceCheck instance.

Source code in src/msl/equipment/schema.py
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
@classmethod
def from_xml(cls, element: Element[str]) -> PerformanceCheck:
    """Convert an XML element into a [PerformanceCheck][msl.equipment.schema.PerformanceCheck] instance.

    Args:
        element: A [performanceCheck][type_performanceCheck] XML element from an
            equipment register.

    Returns:
        The [PerformanceCheck][msl.equipment.schema.PerformanceCheck] instance.
    """
    # Schema forces order for `competency` and `conditions` but uses xsd:choice,
    # which allows sub-elements to appear (or not appear) in any order, for the data elements.
    # Using str.endswith() allows for ignoring XML namespaces that may be associated with each tag
    cvd_equations: list[CVDEquation] = []
    equations: list[Equation] = []
    files: list[File] = []
    deserialisers: list[Deserialised] = []
    tables: list[Table] = []
    for child in element[2:]:
        tag = child.tag
        if tag.endswith("equation"):
            equations.append(Equation.from_xml(child))
        elif tag.endswith("table"):
            tables.append(Table.from_xml(child))
        elif tag.endswith("cvdCoefficients"):
            cvd_equations.append(CVDEquation.from_xml(child))
        elif tag.endswith("file"):
            files.append(File.from_xml(child))
        else:
            deserialisers.append(Deserialised.from_xml(child))

    a = element.attrib
    return cls(
        completed_date=_date.fromisoformat(a["completedDate"] or ""),
        entered_by=a["enteredBy"] or "",
        checked_by=a.get("checkedBy", ""),
        checked_date=None if not a.get("checkedDate") else _date.fromisoformat(a["checkedDate"]),
        competency=Competency.from_xml(element[0]),
        conditions=Conditions.from_xml(element[1]),
        cvd_equations=tuple(cvd_equations),
        deserialisers=tuple(deserialisers),
        equations=tuple(equations),
        files=tuple(files),
        tables=tuple(tables),
    )

to_xml ¤

to_xml() -> Element[str]

Convert the PerformanceCheck class into an XML element.

Returns:

Type Description
Element[str]

The PerformanceCheck as an XML element.

Source code in src/msl/equipment/schema.py
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
def to_xml(self) -> Element[str]:
    """Convert the [PerformanceCheck][msl.equipment.schema.PerformanceCheck] class into an XML element.

    Returns:
        The [PerformanceCheck][msl.equipment.schema.PerformanceCheck] as an XML element.
    """
    a = {"completedDate": self.completed_date.isoformat(), "enteredBy": self.entered_by}
    if self.checked_by:
        a["checkedBy"] = self.checked_by
    if self.checked_date is not None:
        a["checkedDate"] = self.checked_date.isoformat()

    e = Element("performanceCheck", attrib=a)
    e.append(self.competency.to_xml())
    e.append(self.conditions)
    e.extend(equation.to_xml() for equation in self.equations)
    e.extend(table.to_xml() for table in self.tables)
    e.extend(cvd.to_xml() for cvd in self.cvd_equations)
    e.extend(file.to_xml() for file in self.files)
    e.extend(deserialised.to_xml() for deserialised in self.deserialisers)
    return e