Skip to content

PlannedTask¤

PlannedTask dataclass ¤

PlannedTask(
    task: str, due_date: date, performed_by: str = ""
)

Represents the plannedTask element in an equipment register.

Parameters:

Name Type Description Default
task str

A description of the task that is planned.

required
due_date date

The date that the planned maintenance task is due to be completed.

required
performed_by str

The person or company that will perform the planned maintenance task.

''

due_date instance-attribute ¤

due_date: date

The date that the planned maintenance task is due to be completed.

performed_by class-attribute instance-attribute ¤

performed_by: str = ''

The person or company that will perform the planned maintenance task.

task instance-attribute ¤

task: str

A description of the task that is planned.

from_xml classmethod ¤

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

Convert an XML element into a PlannedTask instance.

Parameters:

Name Type Description Default
element Element[str]

A plannedTask XML element from an equipment register.

required

Returns:

Type Description
PlannedTask

The PlannedTask instance.

Source code in src/msl/equipment/schema.py
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
@classmethod
def from_xml(cls, element: Element[str]) -> PlannedTask:
    """Convert an XML element into a [PlannedTask][msl.equipment.schema.PlannedTask] instance.

    Args:
        element: A [plannedTask][type_plannedTask] XML element from an equipment register.

    Returns:
        The [PlannedTask][msl.equipment.schema.PlannedTask] instance.
    """
    return cls(
        task=element.text or "",
        due_date=_date.fromisoformat(element.attrib["dueDate"]),
        performed_by=element.get("performedBy", ""),
    )

to_xml ¤

to_xml() -> Element[str]

Convert the PlannedTask class into an XML element.

Returns:

Type Description
Element[str]

The PlannedTask as an XML element.

Source code in src/msl/equipment/schema.py
515
516
517
518
519
520
521
522
523
524
525
526
527
def to_xml(self) -> Element[str]:
    """Convert the [PlannedTask][msl.equipment.schema.PlannedTask] class into an XML element.

    Returns:
        The [PlannedTask][msl.equipment.schema.PlannedTask] as an XML element.
    """
    attrib = {"dueDate": self.due_date.isoformat()}
    if self.performed_by:
        attrib["performedBy"] = self.performed_by

    e = Element("task", attrib=attrib)
    e.text = self.task
    return e