atlasdcat package

Submodules

atlasdcat.attribute module

Attribute module for mapping an Atlas Glossery to DCAT rdf.

class atlasdcat.attribute.Attribute(value)

Bases: str, Enum

Attribute enum.

ACCESS_RIGHTS = 'accessRights'
ACCESS_URL = 'accessURL'
CONTACT_EMAIL = 'contactEmail'
CONTACT_NAME = 'contactName'
DATASET = 'Dataset'
DISTRIBUTION = 'Distribution'
DOWNLOAD_URL = 'downloadURL'
FORMAT = 'format'
FREQUENCY = 'frequency'
GENERATED = 'generated'
INCLUDE_IN_DCAT = 'includeInDCAT'
KEYWORD = 'keyword'
LICENSE = 'license'
PUBLISHER = 'publisher'
SPATIAL = 'spatial'
SPATIAL_RESOLUTION_IN_METERS = 'spatialResolutionInMeters'
TEMPORAL_END_DATE = 'temporalEndDate'
TEMPORAL_RESOLUTION = 'temporalResolution'
TEMPORAL_START_DATE = 'temporalStartDate'
THEME = 'theme'
TITLE = 'title'

atlasdcat.glossaryclient module

AtlasClient module for mapping an Atlas Glossery to DCAT rdf.

class atlasdcat.glossaryclient.AtlasGlossaryClient(endpoint_url, authentication, **kwargs)

Bases: GlossaryClient

Class for Atlas Glossary REST Client.

update_term(term, **kwargs)

Update a single term to Apache Atlas.

Provide an AtlasGlossaryTerm or dictionary.

Parameters
  • term (Union[Dict, _CrossPlatformTerm]) – The term to be updated.

  • kwargs (Dict) – The parameters to pass into the url.

Return type

Dict

Returns

The updated term’s current state.

Raises

TypeError – A type error

atlasdcat.mapper module

Mapper module for mapping an Atlas Glossery to DCAT rdf.

This module contains methods for mapping an Atlas Glossery to DCAT rdf according to the dcat-ap-no v.2 standard

Example

Setup the AtlasDcatMapper. >>> from atlasdcat import AtlasDcatMapper, AtlasGlossaryClient >>> from pyapacheatlas.auth import BasicAuthentication >>> >>> atlas_auth = BasicAuthentication(username=”dummy”, password=”dummy”) >>> atlas_client = AtlasGlossaryClient( >>> endpoint_url=”http://atlas”, authentication=atlas_auth >>> ) >>> >>> mapper = AtlasDcatMapper( >>> glossary_client=atlas_client, >>> glossary_id=”myglossary”, >>> catalog_uri=”https://example.com/catalog”, >>> catalog_language=”http://publications.europa.eu/resource/authority/language/NOB”, >>> catalog_title=”Catalog”, >>> catalog_publisher=”https://domain/publisher”, >>> dataset_uri_template=”http://domain/datasets/{guid}”, >>> distribution_uri_template=”http://domain/distributions/{guid}”, >>> language=”nb”, >>> )

Map glossary terms to DCAT Catalog >>> try: >>> mapper.fetch_glossary() >>> catalog = mapper.map_glossary_terms_to_dataset_catalog() >>> print(catalog.to_rdf()) >>> except Exception as e: >>> print(f”An exception occurred: {e}”)

>>> catalog = Catalog()
>>> catalog.identifier = "http://catalog-uri"
>>> catalog.title = {"nb": "mytitle"}
>>> catalog.publisher = "http://publisher"
>>> catalog.language = ["nb"]
>>> catalog.license = ""
>>> dataset = Dataset()
>>> dataset.title = {"nb": "Dataset"}
>>> dataset.description = {"nb": "Dataset description"}
>>> catalog.datasets = [dataset]
>>>
>>> try:
>>>  6+
 mapper.fetch_glossary()
        mapper.map_dataset_catalog_to_glossary_terms(catalog)
        mapper.save_glossary_terms()
    except Exception as e:
        print(f"An exception occurred: {e}")
class atlasdcat.mapper.AtlasDcatMapper(glossary_client, glossary_id, catalog_uri, catalog_language, catalog_title, catalog_publisher, dataset_uri_template, distribution_uri_template, language='nb', attr_mapping=None, is_purview=None, include_approved_only=False)

Bases: object

Class for mapping Atlas Glossary terms to DCAT catalog.

fetch_glossary()

Fetch detailed glossary.

Return type

None

property glossary_terms: List[Dict]

List[Dict], the persisted glossary terms.

Return type

List[Dict]

map_dataset_catalog_to_glossary_terms(catalog)

Map dcat dataset catalog RDF resource to glossary terms.

Parameters

catalog (Catalog) – A dataset catalog RDF resource

Raises
Return type

None

map_glossary_terms_to_dataset_catalog()

Map glossary terms to dcat dataset catalog RDF resource.

Return type

Catalog

Returns

A catalog RDF resource.

Raises

InvalidStateError – If glossary is not fetched before calling this function

save_glossary_terms()

Save glossary terms.

Raises

InvalidStateError – If there are no terms to save.

Return type

None

property tmp_glossary_terms: List[Dict]

Dict, the temporary glossary terms.

Return type

List[Dict]

exception atlasdcat.mapper.FormatError

Bases: MappingError

Exception class for format errors.

exception atlasdcat.mapper.InvalidStateError

Bases: MappingError

Exception class for invalid state errors.

exception atlasdcat.mapper.MappingError

Bases: Exception

Exception class for mapping errors.

exception atlasdcat.mapper.TemporalError

Bases: MappingError

Exception class for temporal errors.

atlasdcat.termtype module

Termtype module for mapping an Atlas Glossery to DCAT rdf.

class atlasdcat.termtype.TermType(value)

Bases: Enum

Term type enum.

DATASET = 1
DISTRIBUTION = 2
UNKNOWN = -1

Module contents

atlasdcat package.