dicogis.export.base_serializer module

class dicogis.export.base_serializer.MetadatasetSerializerBase(localized_strings=None, output_path=None, opt_raw_path=False, opt_size_prettify=True)

Bases: object

Base class for metadataset serializers.

__init__(localized_strings=None, output_path=None, opt_raw_path=False, opt_size_prettify=True)

Initialize object.

classmethod get_serializer_from_parameters(format_or_serializer, output_path=None, opt_raw_path=False, opt_prettify_size=True, localized_strings=None, language=None, opt_include_original_path=None, catalog_record_settings=None)

Initiate the adequat serializer depending on parameters.

Parameters:
  • format_or_serializer (str | OutputFormats.excel | OutputFormats.json | OutputFormats.udata | OutputFormats.iso19139 | MetadatasetSerializerBase) – output format or serializer

  • output_path (Path | None) – output path

  • opt_raw_path (bool) – option to serialize dataset raw path without any sugar syntax

  • opt_prettify_size (bool) – option to prettify size in octets (typically: 1 ko instead of 1024 octects)

  • localized_strings (dict | None) – localized texts. Defaults to None.

  • language (str | tuple | None) – language of the metadata records (iso19139). Defaults to None, which means English.

  • opt_include_original_path (bool | None) – publish the location of the datasets in the metadata records (iso19139). Defaults to the DICOGIS_ISO_INCLUDE_ORIGINAL_PATH environment variable.

  • catalog_record_settings (CatalogRecordSettings | None) – settings of the metadata records (iso19139), built by the caller. Replaces language and opt_include_original_path, and the environment variables.

Return type:

MetadatasetSerializerBase

Returns:

serializer already initialized

post_serializing(**kwargs)

Operations to run after serialization.

Return type:

None

pre_serializing(**kwargs)

Operations to run before serialization.

Return type:

None

unique_output_filename(dataset_name, extension)

Pick the name of a per-dataset output file, unique within this run.

Datasets are often homonyms (lines.shp in several folders): suffixed with a counter rather than overwriting the one written before.

Parameters:
  • dataset_name (str) – name of the dataset, slugified to build the file name

  • extension (str) – file extension, with its leading dot

Return type:

str

Returns:

file name, not used yet during this run and now reserved