niamoto.core.plugins.transformers.formats package

Submodules

niamoto.core.plugins.transformers.formats.niamoto_to_dwc_occurrence module

Transformer plugin for converting Niamoto data to Darwin Core Occurrence format.

This transformer maps Niamoto taxon occurrence data to the Darwin Core standard, which is widely used for biodiversity data exchange.

class niamoto.core.plugins.transformers.formats.niamoto_to_dwc_occurrence.NiamotoDwCConfig(*, plugin='niamoto_to_dwc_occurrence', source=None, params)

Bases: PluginConfig

Configuration for Darwin Core transformer plugin.

Parameters:
plugin: Literal['niamoto_to_dwc_occurrence']
params: DwcTransformerParams
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class niamoto.core.plugins.transformers.formats.niamoto_to_dwc_occurrence.NiamotoDwCTransformer(db, registry=None)

Bases: TransformerPlugin

Transform Niamoto data to Darwin Core Occurrence format.

Parameters:

db (Any)

config_model

alias of NiamotoDwCConfig

param_schema

alias of DwcTransformerParams

validate_config(config)

Validate the configuration using Pydantic model.

Parameters:

config (Dict[str, Any]) – Configuration dictionary to validate

Returns:

Validated NiamotoDwCConfig instance

Raises:

ValueError – If configuration is invalid

Return type:

NiamotoDwCConfig

transform(data, config)

Transform Niamoto taxon data to Darwin Core occurrences.

Parameters:
  • data (Dict[str, Any]) – Niamoto taxon data with occurrences

  • config (Dict[str, Any]) – Configuration dictionary with params

Returns:

List of Darwin Core formatted occurrences

Return type:

List[Dict[str, Any]]

prepare_batch(items, config)

Preload occurrences for the current group to avoid one query per taxon.

Parameters:
  • items (List[Dict[str, Any]])

  • config (Dict[str, Any] | PluginConfig)

Return type:

None

Module contents

Format Conversion Transformers

This module contains transformers specialized in converting data between different formats and standards. These transformers typically take structured data and transform it to comply with external standards or APIs.

Available transformers: - niamoto_to_dwc_occurrence: Convert Niamoto data to Darwin Core Occurrence format

class niamoto.core.plugins.transformers.formats.NiamotoDwCTransformer(db, registry=None)

Bases: TransformerPlugin

Transform Niamoto data to Darwin Core Occurrence format.

Parameters:

db (Any)

config_model

alias of NiamotoDwCConfig

param_schema

alias of DwcTransformerParams

prepare_batch(items, config)

Preload occurrences for the current group to avoid one query per taxon.

Parameters:
  • items (List[Dict[str, Any]])

  • config (Dict[str, Any] | PluginConfig)

Return type:

None

transform(data, config)

Transform Niamoto taxon data to Darwin Core occurrences.

Parameters:
  • data (Dict[str, Any]) – Niamoto taxon data with occurrences

  • config (Dict[str, Any]) – Configuration dictionary with params

Returns:

List of Darwin Core formatted occurrences

Return type:

List[Dict[str, Any]]

validate_config(config)

Validate the configuration using Pydantic model.

Parameters:

config (Dict[str, Any]) – Configuration dictionary to validate

Returns:

Validated NiamotoDwCConfig instance

Raises:

ValueError – If configuration is invalid

Return type:

NiamotoDwCConfig