antimatter.handlers.dict_list#

Module Contents#

Classes#

DictList

The DictList DataHandler supports a list of dictionaries.

class antimatter.handlers.dict_list.DictList#

Bases: antimatter.handlers.base.DataHandler

The DictList DataHandler supports a list of dictionaries.

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

from_generic takes the generic data and passes it on as a list of dictionaries

Parameters:
  • cols – the column names

  • generic_data

the capsule’s generic data format holding the row values :param extra: extra data for the DataHandler :return: the data in a dictionary list format

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

to_generic converts a list of dictionaries into the generic data format, which is essentially a no-op as DictList has the same format as generic

Parameters:

data – the list of dictionaries to pass across as generic format

Returns:

the data in its generic form

field_converter_from_generic(ft: antimatter.fieldtype.fieldtypes.FieldType) Callable[[bytes], Any]#

field_converter_from_generic gets a field converter function for the given field type that can be used to convert fields from their generic string type to their specific type.

Note that these statement should be true for all implementations, given FieldType ft.

from_gen = field_converter_from_generic(ft) to_gen = field_converter_to_generic(ft)

generic_value == to_gen(from_gen(generic_value)) field_value == from_gen(to_gen(field_value))

Parameters:

ft – the FieldType to get the converter function for

Returns:

a function that can convert field values from generic form

field_converter_to_generic(ft: antimatter.fieldtype.fieldtypes.FieldType) Callable[[Any], bytes]#

field_converter_to_generic gets a field converter function for the given field type that can be used to convert fields from their specific type to their generic type.

Note that these statement should be true for all implementations, given FieldType ft.

from_gen = field_converter_from_generic(ft) to_gen = field_converter_to_generic(ft)

generic_value == to_gen(from_gen(generic_value)) field_value == from_gen(to_gen(field_value))

Parameters:

ft – the FieldType to get the converter function for

Returns:

a function that can convert field values to generic form