antimatter.extra_helper#

Module Contents#

Functions#

extra_for_session(→ Dict[str, Any])

Arranges an 'extra' dictionary for a Session using the given Datatype

extra_for_capsule(→ Dict[str, Any])

Arranges an 'extra' dictionary for a Capsule using the given Datatype to

get_field_type(→ antimatter.fieldtype.fieldtypes.FieldType)

Helper function to get the field type from a Capsule level 'extra' dictionary

without_meta(→ Optional[Dict[str, Any]])

Helper function to strip special metadata keys from the provided 'extra'

Attributes#

antimatter.extra_helper.META_TYPE_KEY = '_metadtype'#
antimatter.extra_helper.COL_TYPE_KEY = '_coltype'#
antimatter.extra_helper.DTYPE_KEY = '_dtype'#
antimatter.extra_helper.ALL_META_KEYS#
antimatter.extra_helper.extra_for_session(dt: antimatter.datatype.datatypes.Datatype, from_capsule: Dict[str, Any], session_extra: Dict[str, Any] | None = None) Dict[str, Any]#

Arranges an ‘extra’ dictionary for a Session using the given Datatype and the ‘extra’ dictionary built from a handler’s “to_generic” method. If an existing session “extra” dictionary is provided, it will be updated with the additional information.

Parameters:
  • dt – the Datatype for the capsule data

  • from_capsule – the ‘extra’ data from the capsule level generic handling

  • session_extra – an optional existing Session level ‘extra’ dict

Returns:

a Session level ‘extra’ dict for passing metadata to a Capsule

antimatter.extra_helper.extra_for_capsule(dt: antimatter.datatype.datatypes.Datatype, session_extra: Dict[str, Any] | None, **kwargs) Dict[str, Any]#

Arranges an ‘extra’ dictionary for a Capsule using the given Datatype to load the Capsule in and the Session level ‘extra’ dictionary. If kwargs are provided, they will be passed as-is to the ‘extra’ dictionary.

Parameters:
  • dt – the Datatype for the Capsule data

  • session_extra – the Session level ‘extra’ dict

  • kwargs – the kwargs passed to a Capsule for reading data

Returns:

a Capsule level ‘extra’ dict for passing metadata to a data handler

antimatter.extra_helper.get_field_type(col_name: str, extra: Dict[str, Any] | None, default: antimatter.fieldtype.fieldtypes.FieldType = FieldType.String) antimatter.fieldtype.fieldtypes.FieldType#

Helper function to get the field type from a Capsule level ‘extra’ dictionary for the provided column name, falling back to the default value.

Parameters:
  • col_name – the name of the column to get the field type metadata for

  • extra – the Capsule level ‘extra’ dict containing handler metadata

  • default – fallback FieldType value (String by default)

Returns:

the FieldType of the given column as found in the ‘extra’ metadata

antimatter.extra_helper.without_meta(extra: Dict[str, Any] | None) Dict[str, Any] | None#

Helper function to strip special metadata keys from the provided ‘extra’ dictionary. A new copy of the dictionary is made and returned.

Parameters:

extra – the ‘extra’ dict to strip special metadata from

Returns:

the ‘extra’ dict wtih special metadata stripped