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, ...] = (),
    equations: tuple[Equation, ...] = (),
    files: tuple[File, ...] = (),
    deserialised: tuple[Deserialised, ...] = (),
    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.

required
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 coefficients for the Callendar-Van Dusen equation.

()
equations tuple[Equation, ...]

Performance-check data is expressed as an equation.

()
files tuple[File, ...]

Performance-check data is stored in another file (not in the equipment register).

()
deserialised tuple[Deserialised, ...]

Performance-check data is stored in a serialised format and deserialised.

()
tables tuple[Table, ...]

Performance-check data is expressed as a CSV table in the equipment register.

()

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_equations class-attribute instance-attribute ¤

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

Performance-check data is expressed as coefficients for the Callendar-Van Dusen equation.

deserialised class-attribute instance-attribute ¤

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

Performance-check data is stored in a serialised format and deserialised.

entered_by instance-attribute ¤

entered_by: str

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

equations class-attribute instance-attribute ¤

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

Performance-check data is expressed as an equation.

files class-attribute instance-attribute ¤

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

Performance-check data is stored in another file (not in the equipment register).

tables class-attribute instance-attribute ¤

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

Performance-check data is expressed as a CSV table in the equipment register.

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
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
@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] = []
    deserialised: 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:
            deserialised.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),
        equations=tuple(equations),
        files=tuple(files),
        deserialised=tuple(deserialised),
        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
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
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.deserialised)
    return e