Skip to content

Report¤

Report dataclass ¤

Report(
    id: str,
    report_issue_date: date,
    measurement_start_date: date,
    measurement_stop_date: date,
    issuing_laboratory: IssuingLaboratory = IssuingLaboratory(),
    technical_procedure: str = "",
    entered_by: str = "",
    checked_by: str = "",
    checked_date: date | None = None,
    conditions: Conditions = Conditions(),
    acceptance_criteria: AcceptanceCriteria = AcceptanceCriteria(),
    cvd_equations: tuple[CVDEquation, ...] = (),
    deserialisers: tuple[Deserialised, ...] = (),
    equations: tuple[Equation, ...] = (),
    files: tuple[File, ...] = (),
    tables: tuple[Table, ...] = (),
)

Represents the report element in an equipment register.

Parameters:

Name Type Description Default
id str

The report identification number.

required
report_issue_date date

The date that the report was issued.

required
measurement_start_date date

The date that the calibration measurement started.

required
measurement_stop_date date

The date that the calibration measurement stopped.

required
issuing_laboratory IssuingLaboratory

Information about the laboratory that issued the calibration report.

IssuingLaboratory()
technical_procedure str

The technical procedure(s) that was(were) followed to perform the calibration.

''
entered_by str

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

''
checked_by str

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

''
checked_date date | None

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

None
conditions Conditions

The conditions under which the report is valid.

Conditions()
acceptance_criteria AcceptanceCriteria

Acceptance criteria for the calibration report.

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

Calibration data is expressed as Callendar-Van Dusen equations.

()
deserialisers tuple[Deserialised, ...]

Calibration data is stored in serialised formats and deserialised.

()
equations tuple[Equation, ...]

Calibration data is expressed as equations.

()
files tuple[File, ...]

Calibration data is stored in other files (not in the equipment register).

()
tables tuple[Table, ...]

Calibration data is stored as Comma Separated Values (CSV) tables.

()

acceptance_criteria class-attribute instance-attribute ¤

acceptance_criteria: AcceptanceCriteria = field(
    default_factory=AcceptanceCriteria
)

Acceptance criteria for the calibration report.

checked_by class-attribute instance-attribute ¤

checked_by: str = ''

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

checked_date class-attribute instance-attribute ¤

checked_date: date | None = None

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

conditions class-attribute instance-attribute ¤

conditions: Conditions = field(default_factory=Conditions)

The conditions under which the report is valid.

cvd_equation property ¤

cvd_equation: CVDEquation

Returns the first item in the cvd_equations tuple.

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

cvd_equations class-attribute instance-attribute ¤

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

Calibration data is expressed as Callendar-Van Dusen equations.

deserialised property ¤

deserialised: Deserialised

Returns the first item in the deserialisers tuple.

Raises IndexError if the report does not contain serialised data.

deserialisers class-attribute instance-attribute ¤

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

Calibration 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 <report> element in the register.

equation property ¤

equation: Equation

Returns the first item in the equations tuple.

Raises IndexError if the report does not contain equations.

equations class-attribute instance-attribute ¤

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

Calibration data is expressed as equations.

file property ¤

file: File

Returns the first item in the files tuple.

Raises IndexError if the report does not contain files.

files class-attribute instance-attribute ¤

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

Calibration data is stored in other files (not in the equipment register).

id instance-attribute ¤

id: str

The report identification number.

issuing_laboratory class-attribute instance-attribute ¤

issuing_laboratory: IssuingLaboratory = field(default_factory=IssuingLaboratory)

Information about the laboratory that issued the calibration report.

measurement_start_date instance-attribute ¤

measurement_start_date: date

The date that the calibration measurement started.

measurement_stop_date instance-attribute ¤

measurement_stop_date: date

The date that the calibration measurement stopped.

report_issue_date instance-attribute ¤

report_issue_date: date

The date that the report was issued.

table property ¤

table: Table

Returns the first item in the tables tuple.

Raises IndexError if the report does not contain tables.

tables class-attribute instance-attribute ¤

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

Calibration data is stored as Comma Separated Values (CSV) tables.

technical_procedure class-attribute instance-attribute ¤

technical_procedure: str = ''

The technical procedure(s) that was(were) followed to perform the calibration.

from_xml classmethod ¤

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

Convert an XML element into a Report instance.

Parameters:

Name Type Description Default
element Element[str]

A report XML element from an equipment register.

required

Returns:

Type Description
Report

The Report instance.

Source code in src/msl/equipment/schema.py
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
@classmethod
def from_xml(cls, element: Element[str]) -> Report:
    """Convert an XML element into a [Report][msl.equipment.schema.Report] instance.

    Args:
        element: A [report][type_report] XML element from an equipment register.

    Returns:
        The [Report][msl.equipment.schema.Report] instance.
    """
    # Schema forces order until `acceptanceCriteria` and then 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] = []
    deserialisers: list[Deserialised] = []
    equations: list[Equation] = []
    files: list[File] = []
    tables: list[Table] = []
    for child in element[7:]:
        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(
        id=a["id"] or "",
        entered_by=a["enteredBy"] or "",
        checked_by=a.get("checkedBy", ""),
        checked_date=None if not a.get("checkedDate") else _date.fromisoformat(a["checkedDate"]),
        report_issue_date=_date.fromisoformat(element[0].text or ""),
        measurement_start_date=_date.fromisoformat(element[1].text or ""),
        measurement_stop_date=_date.fromisoformat(element[2].text or ""),
        issuing_laboratory=IssuingLaboratory.from_xml(element[3]),
        technical_procedure=element[4].text or "",
        conditions=Conditions.from_xml(element[5]),
        acceptance_criteria=AcceptanceCriteria.from_xml(element[6]),
        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 Report class into an XML element.

Returns:

Type Description
Element[str]

The Report as an XML element.

Source code in src/msl/equipment/schema.py
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
def to_xml(self) -> Element[str]:
    """Convert the [Report][msl.equipment.schema.Report] class into an XML element.

    Returns:
        The [Report][msl.equipment.schema.Report] as an XML element.
    """
    a = {"id": self.id, "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("report", attrib=a)

    rid = SubElement(e, "reportIssueDate")
    rid.text = self.report_issue_date.isoformat()

    start = SubElement(e, "measurementStartDate")
    start.text = self.measurement_start_date.isoformat()

    stop = SubElement(e, "measurementStopDate")
    stop.text = self.measurement_stop_date.isoformat()

    e.append(self.issuing_laboratory.to_xml())

    tp = SubElement(e, "technicalProcedure")
    tp.text = self.technical_procedure

    e.append(self.conditions)
    e.append(self.acceptance_criteria)
    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

IssuingLaboratory dataclass ¤

IssuingLaboratory(lab: str = '', person: str = '')

Information about the laboratory that issued a calibration report.

Parameters:

Name Type Description Default
lab str

The name of the laboratory that issued the calibration report.

''
person str

The name of a person at the laboratory that authorised the report.

''

lab class-attribute instance-attribute ¤

lab: str = ''

The name of the laboratory that issued the calibration report.

person class-attribute instance-attribute ¤

person: str = ''

The name of a person at the laboratory that authorised the report.

from_xml classmethod ¤

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

Convert an XML element into a IssuingLaboratory instance.

Parameters:

Name Type Description Default
element Element[str]

An <issuingLaboratory> element from a report element in an equipment register.

required

Returns:

Type Description
IssuingLaboratory

The IssuingLaboratory instance.

Source code in src/msl/equipment/schema.py
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
@classmethod
def from_xml(cls, element: Element[str]) -> IssuingLaboratory:
    """Convert an XML element into a [IssuingLaboratory][msl.equipment.schema.IssuingLaboratory] instance.

    Args:
        element: An `<issuingLaboratory>` element from a [report][type_report] element
            in an equipment register.

    Returns:
        The [IssuingLaboratory][msl.equipment.schema.IssuingLaboratory] instance.
    """
    return cls(
        lab=element.text or "",
        person=element.attrib.get("person", ""),
    )

to_xml ¤

to_xml() -> Element[str]

Convert the IssuingLaboratory class into an XML element.

Returns:

Type Description
Element[str]

The IssuingLaboratory as an XML element.

Source code in src/msl/equipment/schema.py
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
def to_xml(self) -> Element[str]:
    """Convert the [IssuingLaboratory][msl.equipment.schema.IssuingLaboratory] class into an XML element.

    Returns:
        The [IssuingLaboratory][msl.equipment.schema.IssuingLaboratory] as an XML element.
    """
    a = {"person": self.person} if self.person else {}
    e = Element("issuingLaboratory", attrib=a)
    e.text = self.lab
    return e