dcc_quantities.serializers.content_data

General parser functions to be applied over XML files.

dcc_type_collector

dcc_type_collector(
    dcc_data: dict | list, search_keys: Sequence[str]
) -> list[tuple[list[str], DccType]]

Searches a JSON-like dict for keys in search_keys.

Parameters:
  • dcc_data (dict | list) –

    Serialized DCC data. This can either be a dictionary (extracted directly from the XML) or a sequence of the DCC elements. Any sequence is then converted to a dictionary, where the keys are the numerical index corresponding to the position of each element in the sequence.

  • search_keys (Sequence[str]) –

    Element keys to search within the json dictionary to be extracted.

Returns:
  • results( list[tuple[list[str], DccType]] ) –

    Sequence of items as (path, value), where: - path is the hierarchical path (as a list of items) from root to the value - value is the decoded DCC data as the corresponding instance (depending on the

extract_dcc_tables

extract_dcc_tables(dcc_file_path: str, schema_version: str | None = None) -> list[dict]

Extracts all the quantity tables from DCC data.

Parameters:
  • dcc_file_path (str) –

    Path to the file containing the DCC data. The data can correspond either to a complete DCC or just to a portion of it (subschema), considering the data is a valid XML structure following the DCC rules.

  • schema_version (str | None, default: None ) –

    String specifying the version of the provided DCC data. This parameter is only strictly required if the DCC data is a subschema without the attribute schemaVersion within it.

Returns:
  • list of dict

    A sequence with all the tables contained within the provided file. Each table is represented as a dictionary that can be immediately serialized into JSON.