amal.eda.ipxact_de package

Subpackages

Submodules

amal.eda.ipxact_de.xml_document module

XML parsing utilities for IP-XACT / SPIRIT documents.

class amal.eda.ipxact_de.xml_document.XmlDocument(path, *, auto_parse=True)

Bases: object

Represents a parsed IP-XACT/SPIRIT XML document.

Attributes

path: Path

Path to the original XML file.

tree: etree._ElementTree | None

Parsed XML tree (None until parsing succeeds).

schema: str | None

Resolved schema location (index.xsd path) if discovered.

version: str | None

Version string in the form ‘IPXACT/1685-2022’ or ‘SPIRIT/1.5’.

root_name: str | None

Root element name.

is_spirit: bool

True if the file namespace matches SPIRIT.

is_ipxact: bool

True if the file namespace matches IP-XACT.

classmethod deserialize(xml, cls_type)

Deserialize xml string into an instance of cls_type.

Parameters

xml: str

XML text to parse.

cls_type: type[T]

Target dataclass type.

Returns

T

The deserialized object instance.

Parameters:
  • xml (str)

  • cls_type (type[T])

Return type:

T

parse()

Parse the XML document if not already parsed.

This populates tree, schema, standard, version, root_name, and flags. Subsequent calls are no-ops.

Return type:

None

classmethod parser()

Return a shared XmlParser instance.

Returns

XmlParser

The singleton parser bound to the shared XML context.

Return type:

XmlParser

serialize(obj)

Serialize obj using the shared serializer.

Parameters

obj: object

The dataclass instance to serialize.

Returns

str

The serialized XML content.

Parameters:

obj (object)

Return type:

str

classmethod serializer()

Return a shared XmlSerializer instance.

Returns

XmlSerializer

The singleton serializer configured with two-space indentation.

Return type:

XmlSerializer

Parameters:
  • path (Path)

  • auto_parse (bool)

Module contents