dcclib.extraction

DCCFile dataclass

DCCFile(name: list[StringWithLang], file_name: str, mime_type: str, data_base64: str, ring: Ring)

Dataclass that represents a file in the DCC.

decode_data_base64

decode_data_base64() -> bytes

Decode the base64 data.

Returns:
  • bytes –

    the bytes of the decoded data

DCCFunction dataclass

DCCFunction(name: str, expression: str | Expr, variables: dict[str, Value], bound_variables: set[str])

Bases: Generic[T]

Represents a named, parameterised DCC formula.

combinations property

combinations: list[Any]

Return one lambdified function per evaluation step (one per combination index).

The number of entries matches the number of results "evaluate()" would return.

Extractable

Bases: ABC

Abstract base class for classes that can extract information.

extract abstractmethod

extract()

Extract information from the object.

FileExtractor

FileExtractor(xml_tree: etree.Element)

Bases: Constructible, Extractable

Class to extract files from a DCC XML file.

extract

extract() -> list[DCCFile]

Extract files from the DCC XML.

Returns:
  • list[DCCFile] –

    a list of DCCFile objects

from_file classmethod

from_file(path: str)

Create a FileExtractor from a DCC XML file path.

Parameters:
  • path (str) –

    the path to the DCC XML file

Returns:
  • –

    the FileExtractor

from_str classmethod

from_str(xml: str)

Create a FileExtractor from a DCC XML string.

Parameters:
  • xml (str) –

    the DCC XML string

Returns:
  • –

    the FileExtractor

from_tree classmethod

from_tree(tree: etree.Element)

Create a FileExtractor from an etree.Element tree.

Parameters:
  • tree (etree.Element) –

    the etree.Element tree

Returns:
  • –

    the FileExtractor

FormulaExtractor

FormulaExtractor(element: etree.Element)

Bases: Constructible, Extractable

extract

extract() -> list[DCCFunction[DccQuantityType]]

Extract formulas from the XML.

Returns:
  • list[DCCFunction[DccQuantityType]] –

    a list of DCCFunction objects

from_file classmethod

from_file(path: str)

Create a FormulaExtractor from a file path.

Parameters:
  • path (str) –

    the path to the file

Returns:
  • –

    the FormulaExtractor

from_str classmethod

from_str(xml: str)

Create a FormulaExtractor from a string.

Parameters:
  • xml (str) –

    the XML string

Returns:
  • –

    the FormulaExtractor

from_tree classmethod

from_tree(tree: etree.Element)

Create a FormulaExtractor from an ElementTree.

Parameters:
  • tree (etree.Element) –

    the ElementTree

Returns:
  • –

    the FormulaExtractor

extractable

Extractable

Bases: ABC

Abstract base class for classes that can extract information.

extract abstractmethod

extract()

Extract information from the object.

files

DCCFile dataclass

DCCFile(name: list[StringWithLang], file_name: str, mime_type: str, data_base64: str, ring: Ring)

Dataclass that represents a file in the DCC.

decode_data_base64

decode_data_base64() -> bytes

Decode the base64 data.

Returns:
  • bytes –

    the bytes of the decoded data

FileExtractor

FileExtractor(xml_tree: etree.Element)

Bases: Constructible, Extractable

Class to extract files from a DCC XML file.

extract

extract() -> list[DCCFile]

Extract files from the DCC XML.

Returns:
  • list[DCCFile] –

    a list of DCCFile objects

from_file classmethod

from_file(path: str)

Create a FileExtractor from a DCC XML file path.

Parameters:
  • path (str) –

    the path to the DCC XML file

Returns:
  • –

    the FileExtractor

from_str classmethod

from_str(xml: str)

Create a FileExtractor from a DCC XML string.

Parameters:
  • xml (str) –

    the DCC XML string

Returns:
  • –

    the FileExtractor

from_tree classmethod

from_tree(tree: etree.Element)

Create a FileExtractor from an etree.Element tree.

Parameters:
  • tree (etree.Element) –

    the etree.Element tree

Returns:
  • –

    the FileExtractor

Ring

Bases: Enum

Enum for that represents the location of the element in the DCC.

files

DCCFile dataclass

DCCFile(name: list[StringWithLang], file_name: str, mime_type: str, data_base64: str, ring: Ring)

Dataclass that represents a file in the DCC.

decode_data_base64
decode_data_base64() -> bytes

Decode the base64 data.

Returns:
  • bytes –

    the bytes of the decoded data

FileExtractor

FileExtractor(xml_tree: etree.Element)

Bases: Constructible, Extractable

Class to extract files from a DCC XML file.

extract
extract() -> list[DCCFile]

Extract files from the DCC XML.

Returns:
  • list[DCCFile] –

    a list of DCCFile objects

from_file classmethod
from_file(path: str)

Create a FileExtractor from a DCC XML file path.

Parameters:
  • path (str) –

    the path to the DCC XML file

Returns:
  • –

    the FileExtractor

from_str classmethod
from_str(xml: str)

Create a FileExtractor from a DCC XML string.

Parameters:
  • xml (str) –

    the DCC XML string

Returns:
  • –

    the FileExtractor

from_tree classmethod
from_tree(tree: etree.Element)

Create a FileExtractor from an etree.Element tree.

Parameters:
  • tree (etree.Element) –

    the etree.Element tree

Returns:
  • –

    the FileExtractor

Ring

Bases: Enum

Enum for that represents the location of the element in the DCC.

StringWithLang dataclass

StringWithLang(value: str, lang: str)

Dataclass that represents a string with a language.