Skip to content

DigitalReport¤

DigitalReport dataclass ¤

DigitalReport(
    url: str,
    format: DigitalFormat,
    id: str,
    sha256: str,
    attributes: dict[str, str] = dict(),
    comment: str = "",
)

Represents the digitalReport element in an equipment register.

Parameters:

Name Type Description Default
url str

The location of the digital report. The syntax follows RFC 1738 scheme:scheme-specific-part. If scheme: is not specified, it is assumed to be file:.

required
format DigitalFormat

The format of the digital calibration report.

required
id str

The report identification number.

required
sha256 str

The SHA-256 checksum of the digital report.

required
attributes dict[str, str]

XML attributes associated with the <url> element.

dict()
comment str

A comment to associate with the digital report.

''

attributes class-attribute instance-attribute ¤

attributes: dict[str, str] = field(default_factory=dict)

XML attributes associated with the <url> element.

comment class-attribute instance-attribute ¤

comment: str = ''

A comment associated with the digital report.

format instance-attribute ¤

format: DigitalFormat

The format of the digital calibration report.

id instance-attribute ¤

id: str

The report identification number.

sha256 instance-attribute ¤

sha256: str

The SHA-256 checksum of the digital report.

url instance-attribute ¤

url: str

The location of the digital report. The syntax follows RFC 1738 scheme:scheme-specific-part. If scheme: is not specified, it is assumed to be file:.

from_xml classmethod ¤

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

Convert an XML element into a DigitalReport instance.

Parameters:

Name Type Description Default
element Element[str]

A digitalReport XML element from an equipment register.

required

Returns:

Type Description
DigitalReport

The DigitalReport instance.

Source code in src/msl/equipment/schema.py
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
@classmethod
def from_xml(cls, element: Element[str]) -> DigitalReport:
    """Convert an XML element into a [DigitalReport][msl.equipment.schema.DigitalReport] instance.

    Args:
        element: A [digitalReport][type_digitalReport] XML element from an equipment register.

    Returns:
        The [DigitalReport][msl.equipment.schema.DigitalReport] instance.
    """
    # Schema forces order
    return cls(
        url=element[0].text or "",
        format=DigitalFormat(element.attrib["format"]),
        id=element.attrib["id"],
        sha256=element[1].text or "",
        attributes=element[0].attrib,
        comment=element.attrib.get("comment", ""),
    )

to_xml ¤

to_xml() -> Element[str]

Convert the DigitalReport class into an XML element.

Returns:

Type Description
Element[str]

The DigitalReport as an XML element.

Source code in src/msl/equipment/schema.py
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
def to_xml(self) -> Element[str]:
    """Convert the [DigitalReport][msl.equipment.schema.DigitalReport] class into an XML element.

    Returns:
        The [DigitalReport][msl.equipment.schema.DigitalReport] as an XML element.
    """
    attrib = {"format": self.format.value, "id": self.id}
    if self.comment:
        attrib["comment"] = self.comment
    e = Element("digitalReport", attrib=attrib)
    url = SubElement(e, "url", attrib=self.attributes)
    url.text = self.url
    sha256 = SubElement(e, "sha256")
    sha256.text = self.sha256
    return e

DigitalFormat ¤

Bases: Enum

Represents the digitalFormatEnumerationString enumeration in an equipment register.

Attributes:

Name Type Description
MSL_PDF str

"MSL PDF/A-3" (MSL's PDF/A-3 format).

PTB_DCC str

"PTB DCC" (PTB's Digital Calibration Certificate).