antimatter.handlers.dictionary#

Module Contents#

Classes#

Dictionary

The Dictionary DataHandler supports a single dictionary value with string

class antimatter.handlers.dictionary.Dictionary#

Bases: antimatter.handlers.base.DataHandler

The Dictionary DataHandler supports a single dictionary value with string keys.

from_generic(cols: List[str], generic_data: List[List[bytes]], extra: dict) Dict[str, Any]#

from_generic expects at most one dictionary in the generic data list, and extracts and flattens this dictionary if it can be found

Parameters:
  • cols – the column names; should be the string key values in the dictionary

  • generic_data – the capsule’s generic data format holding the values of the single row

  • extra – extra data for the DataHandler

Returns:

the dictionary value held in the generic data format

to_generic(data: Dict[str, Any]) Tuple[List[str], List[List[bytes]], Dict[str, Any]]#

to_generic converts a single dictionary value into the generic data format, flattening the dictionary into a list and extracting the keys in the key:value pairs as the column names.

Parameters:

data – the dictionary value to wrap into a generic format

Returns:

the data in its generic form