Code reference

Handle TDC-structured metadata.

Submodules

report

Generate reports about TDC-structured metadata.

spreadsheet

Non-standard TDC Excel file format for collecting metadata.

Functions

contains_data_for(mdr, ref_area)

Return True if mdr contains data for ref_area.

dfd_id(mdr)

Return the ID of the dataflow targeted by mdr.

get_cs_common()

Create a shared concept scheme for the concepts referenced by dimensions.

get_msd()

Generate and return the TDC metadata structure definition.

groupby(mds[, key])

Group metadata reports in mds according to a key function.

make_ra(mda_id, value)

Generate a ReportedAttribute for mda_id with the given value.

make_tok(dfd)

Generate a TargetObjectKey that refers to dfd.

map_dims_to_ids(mds)

Return a mapping from unique concept IDs used for dimensions to data flow IDs.

map_values_to_ids(mds, mda_id)

Return a mapping from unique reported attribute values to data flow IDs.

merge_ato(mds)

Extend mds with metadata reports for ATO/ATO data flows.

unique_dfd_id(mdr, existing)

Generate a unique DSD ID for mdr.

transport_data.org.metadata.contains_data_for(mdr: MetadataReport, ref_area: str) bool[source]

Return True if mdr contains data for ref_area.

True is returned if any of the following:

  1. The referenced data flow definition has an ID that starts with ref_area.

  2. The country’s ISO 3166 alpha-2 code, alpha-3 code, official name, or common name appears in the value of the DATA_DESCR metadata attribute.

Parameters:

ref_area (str) – ISO 3166 alpha-2 code for a country. Passed to pycountry.countries.lookup().

transport_data.org.metadata.dfd_id(mdr: MetadataReport) str[source]

Return the ID of the dataflow targeted by mdr.

transport_data.org.metadata.get_cs_common() ConceptScheme[source]

Create a shared concept scheme for the concepts referenced by dimensions.

Concepts in this scheme have an annotation tdc-aka, which is a list of alternate IDs recognized for the concept.

transport_data.org.metadata.get_msd() MetadataStructureDefinition[source]

Generate and return the TDC metadata structure definition.

transport_data.org.metadata.groupby(mds: MetadataSet, key=typing.Callable[[ForwardRef('v21.MetadataReport')], typing.Hashable]) dict[Hashable, list[MetadataReport]][source]

Group metadata reports in mds according to a key function.

Similar to itertools.groupby().

transport_data.org.metadata.make_ra(mda_id: str, value: Any) OtherNonEnumeratedAttributeValue[source]

Generate a ReportedAttribute for mda_id with the given value.

transport_data.org.metadata.make_tok(dfd: BaseDataflow) TargetObjectKey[source]

Generate a TargetObjectKey that refers to dfd.

transport_data.org.metadata.map_dims_to_ids(mds: MetadataSet) dict[str, set[str]][source]

Return a mapping from unique concept IDs used for dimensions to data flow IDs.

transport_data.org.metadata.map_values_to_ids(mds: MetadataSet, mda_id: str) dict[str, set[str]][source]

Return a mapping from unique reported attribute values to data flow IDs.

transport_data.org.metadata.merge_ato(mds: MetadataSet) None[source]

Extend mds with metadata reports for ATO/ATO data flows.

transport_data.org.metadata.unique_dfd_id(mdr: MetadataReport, existing: set[str]) str[source]

Generate a unique DSD ID for mdr.

Classes

TDCALLReportStructure(DATAFLOW, ...)

Concepts and metadata attributes in the TDC metadata structure.