dcclib.conversion

Convertible

Bases: ABC

Abstract base class for classes that can be converted.

convert abstractmethod

convert()

Convert the object.

JSONConverter

JSONConverter(xml: str, version: str)

Bases: Constructible, Convertible

JSONConverter class that converts DCC XML to JSON whilst being schema-aware.

Conversion is delegated to :class:dcc_json_toolkit.DccSchema, which loads and caches the released XSD schema for the detected version.

Constructor for JSONConverter class. @param xml: the DCC XML (complete document or subschema fragment) as a string. @param version: the DCC schema version string (e.g. "3.3.0") used to load the matching XSD schema.

convert

convert() -> str

Convert the DCC XML to JSON. @return: the JSON representation of the DCC XML (or subtree)

from_file classmethod

from_file(path: str)

Create a JSONConverter from a DCC XML file path. @param path: the path to the DCC XML file @return: the JSONConverter

from_str classmethod

from_str(xml: str)

Create a JSONConverter from a DCC XML string. @param xml: the DCC XML string @return: the JSONConverter

from_tree classmethod

from_tree(tree: etree._Element | etree._ElementTree)

Create a JSONConverter from an etree.Element or etree.ElementTree. If a subtree element is passed, the schema version is derived from the enclosing document root. @param tree: the etree.Element or etree.ElementTree @return: the JSONConverter

to_dict

to_dict() -> dict

Convert the DCC XML to a dictionary. @return: the dictionary representation of the DCC XML (or subtree)

convertible

Convertible

Bases: ABC

Abstract base class for classes that can be converted.

convert abstractmethod

convert()

Convert the object.

json_converter

JSONConverter

JSONConverter(xml: str, version: str)

Bases: Constructible, Convertible

JSONConverter class that converts DCC XML to JSON whilst being schema-aware.

Conversion is delegated to :class:dcc_json_toolkit.DccSchema, which loads and caches the released XSD schema for the detected version.

Constructor for JSONConverter class. @param xml: the DCC XML (complete document or subschema fragment) as a string. @param version: the DCC schema version string (e.g. "3.3.0") used to load the matching XSD schema.

convert

convert() -> str

Convert the DCC XML to JSON. @return: the JSON representation of the DCC XML (or subtree)

from_file classmethod

from_file(path: str)

Create a JSONConverter from a DCC XML file path. @param path: the path to the DCC XML file @return: the JSONConverter

from_str classmethod

from_str(xml: str)

Create a JSONConverter from a DCC XML string. @param xml: the DCC XML string @return: the JSONConverter

from_tree classmethod

from_tree(tree: etree._Element | etree._ElementTree)

Create a JSONConverter from an etree.Element or etree.ElementTree. If a subtree element is passed, the schema version is derived from the enclosing document root. @param tree: the etree.Element or etree.ElementTree @return: the JSONConverter

to_dict

to_dict() -> dict

Convert the DCC XML to a dictionary. @return: the dictionary representation of the DCC XML (or subtree)