Reference

datacatalogtordf.resource

Resource module for mapping a sub-classes to rdf.

This module contains methods for mapping a sub-class objects to rdf according to the dcat-ap-no v.2 standard

Refer to sub-class for typical usage examples.

class datacatalogtordf.resource.Resource

Bases: ABC

An abstract class representing a dcat:Resource.

Ref: dcat:Resource.

property access_rights: str

A link to information about who can access the resource or an indication of its security status.

Type

URI

Return type

str

property conforms_to: List[str]

A list of links to established standards to which the described resource conforms.

Type

List[URI]

Return type

List[str]

property contactpoint: Contact

Relevant contact information for the cataloged resource.

Type

Contact

Return type

Contact

property creator: str

Link to the entity responsible for producing the resource.

Type

URI

Return type

str

property description: Dict[str, str]

A free-text account of the item. key is language code.

Type

Dict[str, str]

Return type

Dict[str, str]

classmethod from_json(json)

Convert a JSON (dict).

Parameters

json (Dict) – A dict representing this class.

Returns

The object.

Return type

Resource

property has_policy: str

A link to an ODRL conformant policy expressing the rights associated with the resource.

Type

URI

Return type

str

property identifier: str

A URI uniquely identifying the resource.

Type

URI

Return type

str

property is_referenced_by: List[Resource]

A list of related resources, such as a publication, that references, cites, or otherwise points to the cataloged resource.

Type

List[Resource]

Return type

List[Resource]

property keyword: Dict[str, str]

A keyword or tag describing the resource. key is language code.

Type

Dict[str, str]

Return type

Dict[str, str]

property landing_page: List[str]

A list of links to web pages that can be navigated to in a Web browser to gain access to the catalog, a dataset, its distributions and/or additional information.

Type

List[URI]

Return type

List[str]

property language: List[str]

A list of links to languages of the item.

Type

List[str]

Return type

List[str]

property license: str

A link to a legal document under which the resource is made available.

Type

URI

Return type

str

property modification_date: str

Most recent date on which the item was changed, updated or modified.

Type

Date

Return type

str

property prev: Resource

The previous resource in an ordered collection or series of resources.

Type

Resource

Return type

Resource

property publisher: Union[Agent, str]

A URI uniquely identifying the publisher of the resource.

Type

Union[Agent, str]

Return type

Union[Agent, str]

property qualified_attributions: List[Dict]

List of links to an Agent having some form of responsibility for the resource.

Type

List[Dict]

Return type

List[Dict]

property qualified_relation: List[Relationship]

A list of links to a description of a relationship with another resource.

Type

List[Relationship]

Return type

List[Relationship]

property release_date: str

Date of formal issuance (e.g., publication) of the item.

Type

Date

Return type

str

property resource_relation: List[str]

A list of links to resources with an unspecified relationship to the cataloged item.

Type

List[URI]

Return type

List[str]

property rights: str

license or dct:accessRights, such as copyright statements.

Returns

The link

Return type

str

Type

URI

Type

A link to a statement that concerns all rights not addressed with dct

property theme: List[str]

A list of links to categories of the resource.

Type

List[URI]

Return type

List[str]

property title: Dict[str, str]

A name given to the item. key is langauge code.

Type

Dict[str, str]

Return type

Dict[str, str]

to_json()

Convert the Resource to a json / dict. It will omit the non-initalized fields.

Returns

The json representation of this instance.

Return type

Dict

to_rdf(format='turtle', encoding='utf-8')

Maps the distribution to rdf.

Available formats:
  • turtle (default)

  • xml

  • json-ld

Parameters
  • format (str) – a valid format.

  • encoding (Optional[str]) – the encoding to serialize into

Return type

Union[bytes, str]

Returns

a rdf serialization as a bytes literal according to format.

Example

>>> from datacatalogtordf import Catalog
>>>
>>> catalog = Catalog()
>>> catalog.identifier = "http://example.com/catalogs/1"
>>> catalog.title = {'en': 'Title of catalog'}
>>> bool(catalog.to_rdf())
True
property type_genre: str

A link to the nature or genre of the resource.

Type

URI

Return type

str

datacatalogtordf.relationship

Relationship module for mapping a relationship to rdf.

This module contains methods for mapping a relationship object to rdf according to the dcat-ap-no v.2 standard

Example

>>> from datacatalogtordf import Relationship
>>>
>>> relationship = Relationship()
>>> relationship.identifier = "http://example.com/relations/1"
>>> relationship.title = {"en": "Title of relationship"}
>>>
>>> bool(relationship.to_rdf())
True
class datacatalogtordf.relationship.Relationship(identifier=None)

Bases: object

A class representing a dcat:Relationship.

Ref: dcat:Relationship

classmethod from_json(json)

Convert a JSON (dict).

Parameters

json (Dict) – A dict representing this class.

Returns

The object.

Return type

Relationship

property had_role: str

A URI identifying the role.

Type

URI

Return type

str

property identifier: str

a URI uniquely identifying the resource.

Type

URI

Return type

str

property relation: Resource

A URI uniquely identifying related resource.

Type

Resource

Return type

Resource

to_json()

Convert the Resource to a json / dict. It will omit the non-initalized fields.

Returns

The json representation of this instance.

Return type

Dict

to_rdf(format='turtle', encoding='utf-8')

Maps the relationship to rdf.

Parameters
  • format (str) – a valid format. Default: turtle

  • encoding (Optional[str]) – the encoding to serialize into

Return type

Union[bytes, str]

Returns

a rdf serialization as a bytes literal according to format.

datacatalogtordf.catalog

Catalog module for mapping a catalog to rdf.

This module contains methods for mapping a catalog object to rdf according to the dcat-ap-no v.2 standard

Example

>>> from datacatalogtordf import Catalog, Dataset
>>>
>>> catalog = Catalog()
>>> catalog.identifier = "http://example.com/catalogs/1"
>>> catalog.title = {"en": "Title of catalog"}
>>>
>>> a_dataset = Dataset()
>>> a_dataset.identifier = "http://example.com/datasets/1"
>>> catalog.datasets.append(a_dataset)
>>>
>>> bool(catalog.to_rdf())
True
class datacatalogtordf.catalog.Catalog(identifier=None)

Bases: Dataset

A class representing a dcat:Catalog.

Ref: dcat:Catalog.

property access_rights: str

A link to information about who can access the resource or an indication of its security status.

Type

URI

Return type

str

property access_rights_comments: List[str]

Referanse til hjemmel (kilde for påstand) i offentlighetsloven, sikkerhetsloven, beskyttelsesinstruksen eller annet lovverk som ligger til grunn for vurdering av tilgangsnivå.

Type

List[URI]

Return type

List[str]

property catalogrecords: List[CatalogRecord]

A list of records describing the registration of a single dataset or data service that is part of the catalog.

Type

List[CatalogRecord]

Return type

List[CatalogRecord]

property catalogs: List[Catalog]

A list of catalogs that are of interest in the context of this catalog.

Type

List[Catalog]

Return type

List[Catalog]

property conforms_to: List[str]

A list of links to established standards to which the described resource conforms.

Type

List[URI]

Return type

List[str]

property contactpoint: Contact

Relevant contact information for the cataloged resource.

Type

Contact

Return type

Contact

property creator: str

Link to the entity responsible for producing the resource.

Type

URI

Return type

str

property datasets: List[Dataset]

A list of datasets that is listed in the catalog.

Type

List[Dataset]

Return type

List[Dataset]

property dct_identifier: str

the identifier for the catalog.

Type

str

Return type

str

property description: Dict[str, str]

A free-text account of the item. key is language code.

Type

Dict[str, str]

Return type

Dict[str, str]

property distributions: List[Distribution]

A list of distributions of the dataset.

Type

List[Distribution]

Return type

List[Distribution]

property frequency: str

A link to resource describing the frequency at which dataset is published.

Type

[URI]

Return type

str

classmethod from_json(json)

Convert a JSON (dict).

Parameters

json (Dict) – A dict representing this class.

Returns

The object.

Return type

Resource

property has_parts: List[Catalog]

A list of resources that is listed in the catalog.

Type

List[Catalog]

Return type

List[Catalog]

property has_policy: str

A link to an ODRL conformant policy expressing the rights associated with the resource.

Type

URI

Return type

str

property homepage: str

A link to a homepage for the catalog.

Type

URI

Return type

str

property identifier: str

A URI uniquely identifying the resource.

Type

URI

Return type

str

property in_series: DatasetSeries

A dataset series of which the dataset is part.

Type

DatasetSeries]

Return type

DatasetSeries

property is_referenced_by: List[Resource]

A list of related resources, such as a publication, that references, cites, or otherwise points to the cataloged resource.

Type

List[Resource]

Return type

List[Resource]

property keyword: Dict[str, str]

A keyword or tag describing the resource. key is language code.

Type

Dict[str, str]

Return type

Dict[str, str]

property landing_page: List[str]

A list of links to web pages that can be navigated to in a Web browser to gain access to the catalog, a dataset, its distributions and/or additional information.

Type

List[URI]

Return type

List[str]

property language: List[str]

A list of links to languages of the item.

Type

List[str]

Return type

List[str]

property license: str

A link to a legal document under which the resource is made available.

Type

URI

Return type

str

property modification_date: str

Most recent date on which the item was changed, updated or modified.

Type

Date

Return type

str

property prev: Resource

The previous resource in an ordered collection or series of resources.

Type

Resource

Return type

Resource

property publisher: Union[Agent, str]

A URI uniquely identifying the publisher of the resource.

Type

Union[Agent, str]

Return type

Union[Agent, str]

property qualified_attributions: List[Dict]

List of links to an Agent having some form of responsibility for the resource.

Type

List[Dict]

Return type

List[Dict]

property qualified_relation: List[Relationship]

A list of links to a description of a relationship with another resource.

Type

List[Relationship]

Return type

List[Relationship]

property release_date: str

Date of formal issuance (e.g., publication) of the item.

Type

Date

Return type

str

property resource_relation: List[str]

A list of links to resources with an unspecified relationship to the cataloged item.

Type

List[URI]

Return type

List[str]

property rights: str

license or dct:accessRights, such as copyright statements.

Returns

The link

Return type

str

Type

URI

Type

A link to a statement that concerns all rights not addressed with dct

property services: List[DataService]

A list of dataservices of sites or end-points that is listed in the catalog.

Type

List[DataService]

Return type

List[DataService]

property spatial: List[Union[Location, str]]

A list of geographical areas covered by the dataset.

Type

List[Location]

Return type

List[Union[Location, str]]

property spatial_resolution_in_meters: List[Decimal]

A list of minimum spatial separation resolvables in a dataset, measured in meters.

Type

List[Decimal]

Return type

List[Decimal]

property temporal: List[PeriodOfTime]

A list of temporal periods that the dataset covers.

Type

List[PeriodOfTime]

Return type

List[PeriodOfTime]

property temporal_resolution: List[str]

A list of minimum time period resolvables in the dataset.

Type

List[str]

Return type

List[str]

property theme: List[str]

A list of links to categories of the resource.

Type

List[URI]

Return type

List[str]

property themes: List[str]

A list of links to knowledge organization system (KOS) used to classify catalog.

Type

List[URI`)

Return type

List[str]

property title: Dict[str, str]

A name given to the item. key is langauge code.

Type

Dict[str, str]

Return type

Dict[str, str]

to_json()

Convert the Resource to a json / dict. It will omit the non-initalized fields.

Returns

The json representation of this instance.

Return type

Dict

to_rdf(format='turtle', encoding='utf-8', include_datasets=True, include_services=True)

Maps the catalog to rdf.

Available formats:
  • turtle (default)

  • xml

  • json-ld

Parameters
  • format (str) – a valid format.

  • encoding (str) – the encoding to serialize into

  • include_datasets (bool) – includes the dataset graphs in the catalog

  • include_services (bool) – includes the services in the catalog

Return type

Union[bytes, str]

Returns

a rdf serialization as a bytes literal according to format.

property type_genre: str

A link to the nature or genre of the resource.

Type

URI

Return type

str

property was_generated_by: str

A link to an activity that generated, or provides the business context for, the creation of the dataset.

Type

URI

Return type

str

datacatalogtordf.catalogrecord

CatalogRecord module for mapping a catalogrecord to rdf.

This module contains methods for mapping a catalogrecord object to rdf according to the dcat-ap-no v.2 standard

Example

>>> from datacatalogtordf import CatalogRecord
>>>
>>> catalogrecord = CatalogRecord()
>>> catalogrecord.identifier = "http://example.com/catalogrecords/1"
>>> catalogrecord.title = {"en": "Title of catalogrecord"}
>>>
>>> bool(catalogrecord.to_rdf())
True
class datacatalogtordf.catalogrecord.CatalogRecord(identifier=None)

Bases: object

A class representing a dcat:CatalogRecord.

Ref: https://www.w3.org/TR/vocab-dcat-2/#Class:Catalog_Record

Parameters

identifier (URI) – the identifier of the dataset-series.

property conforms_to: List[str]

An established standard to which the described resource conforms.

Type

List[URI]

Return type

List[str]

property description: Dict[str, str]

A free-text account of the record. key is language code.

Type

Dict[str, str]

Return type

Dict[str, str]

classmethod from_json(json)

Convert a JSON (dict).

Parameters

json (Dict) – A dict representing this class.

Returns

The object.

Return type

CatalogRecord

property identifier: str

a URI uniquely identifying the catalog record.

Type

URI

Return type

str

property listing_date: str

The date of listing.

Type

Date

Return type

str

property modification_date: str

Most recent date on which the catalog entry was changed.

Type

Date

Return type

str

property primary_topic: Resource

Resource (dataset or service) described in the record.

Type

Resource

Type

The dcat

Return type

Resource

property title: Dict[str, str]

A name given to the record. key is language code.

Type

Dict[str, str]

Return type

Dict[str, str]

to_json()

Convert the Resource to a json / dict. It will omit the non-initalized fields.

Returns

The json representation of this instance.

Return type

Dict

to_rdf(format='turtle', encoding='utf-8')

Maps the catalogrecord to rdf.

Return type

Union[bytes, str]

datacatalogtordf.dataservice

DataService module for mapping a dataService to rdf.

This module contains methods for mapping a dataservice object to rdf according to the dcat-ap-no v.2 standard

Example

>>> from datacatalogtordf import DataService
>>>
>>> dataservice = DataService()
>>> dataservice.identifier = "http://example.com/dataservices/1"
>>> dataservice.title = {"en": "Title of dataservice"}
>>>
>>> bool(dataservice.to_rdf())
True
class datacatalogtordf.dataservice.DataService(identifier=None)

Bases: Resource

A class representing a dcat:DataService.

Parameters

identifier (URI) – the identifier of the datasetservice.

Ref: dcat:DataService.

property access_rights: str

A link to information about who can access the resource or an indication of its security status.

Type

URI

Return type

str

property conforms_to: List[str]

A list of links to established standards to which the described resource conforms.

Type

List[URI]

Return type

List[str]

property contactpoint: Contact

Relevant contact information for the cataloged resource.

Type

Contact

Return type

Contact

property creator: str

Link to the entity responsible for producing the resource.

Type

URI

Return type

str

property description: Dict[str, str]

A free-text account of the item. key is language code.

Type

Dict[str, str]

Return type

Dict[str, str]

property endpointDescription: str

A description of the services available via the end-points, including their operations, parameters etc.

Type

URI

Return type

str

property endpointURL: str

The root location or primary endpoint of the service (a Web-resolvable IRI).

Type

URI

Return type

str

classmethod from_json(json)

Convert a JSON (dict).

Parameters

json (Dict) – A dict representing this class.

Returns

The object.

Return type

Resource

property has_policy: str

A link to an ODRL conformant policy expressing the rights associated with the resource.

Type

URI

Return type

str

property identifier: str

A URI uniquely identifying the resource.

Type

URI

Return type

str

property is_referenced_by: List[Resource]

A list of related resources, such as a publication, that references, cites, or otherwise points to the cataloged resource.

Type

List[Resource]

Return type

List[Resource]

property keyword: Dict[str, str]

A keyword or tag describing the resource. key is language code.

Type

Dict[str, str]

Return type

Dict[str, str]

property landing_page: List[str]

A list of links to web pages that can be navigated to in a Web browser to gain access to the catalog, a dataset, its distributions and/or additional information.

Type

List[URI]

Return type

List[str]

property language: List[str]

A list of links to languages of the item.

Type

List[str]

Return type

List[str]

property license: str

A link to a legal document under which the resource is made available.

Type

URI

Return type

str

property media_types: List[str]

A list of media types that is offered in the responses.

Type

List[src]

Return type

List[str]

property modification_date: str

Most recent date on which the item was changed, updated or modified.

Type

Date

Return type

str

property prev: Resource

The previous resource in an ordered collection or series of resources.

Type

Resource

Return type

Resource

property publisher: Union[Agent, str]

A URI uniquely identifying the publisher of the resource.

Type

Union[Agent, str]

Return type

Union[Agent, str]

property qualified_attributions: List[Dict]

List of links to an Agent having some form of responsibility for the resource.

Type

List[Dict]

Return type

List[Dict]

property qualified_relation: List[Relationship]

A list of links to a description of a relationship with another resource.

Type

List[Relationship]

Return type

List[Relationship]

property release_date: str

Date of formal issuance (e.g., publication) of the item.

Type

Date

Return type

str

property resource_relation: List[str]

A list of links to resources with an unspecified relationship to the cataloged item.

Type

List[URI]

Return type

List[str]

property rights: str

license or dct:accessRights, such as copyright statements.

Returns

The link

Return type

str

Type

URI

Type

A link to a statement that concerns all rights not addressed with dct

property servesdatasets: List[Dataset]

A list of datasets that this service serves.

Type

List[Dataset]

Return type

List[Dataset]

property theme: List[str]

A list of links to categories of the resource.

Type

List[URI]

Return type

List[str]

property title: Dict[str, str]

A name given to the item. key is langauge code.

Type

Dict[str, str]

Return type

Dict[str, str]

to_json()

Convert the Resource to a json / dict. It will omit the non-initalized fields.

Returns

The json representation of this instance.

Return type

Dict

to_rdf(format='turtle', encoding='utf-8')

Maps the distribution to rdf.

Available formats:
  • turtle (default)

  • xml

  • json-ld

Parameters
  • format (str) – a valid format.

  • encoding (Optional[str]) – the encoding to serialize into

Return type

Union[bytes, str]

Returns

a rdf serialization as a bytes literal according to format.

Example

>>> from datacatalogtordf import Catalog
>>>
>>> catalog = Catalog()
>>> catalog.identifier = "http://example.com/catalogs/1"
>>> catalog.title = {'en': 'Title of catalog'}
>>> bool(catalog.to_rdf())
True
property type_genre: str

A link to the nature or genre of the resource.

Type

URI

Return type

str

datacatalogtordf.dataset

Dataset module for mapping a dataset to rdf.

This module contains methods for mapping a dataset object to rdf according to the dcat-ap-no v.2 standard

Example

>>> from datacatalogtordf import Dataset, Distribution
>>>
>>> dataset = Dataset()
>>> dataset.identifier = "http://example.com/datasets/1"
>>> dataset.title = {"en": "Title of dataset"}
>>>
>>> a_distribution = Distribution()
>>> a_distribution.identifier = "http://example.com/dataservices/1"
>>> a_distribution.title = {"en": "Title of distribution"}
>>> dataset.distributions.append(a_distribution)
>>>
>>> bool(dataset.to_rdf())
True
class datacatalogtordf.dataset.Dataset(identifier=None)

Bases: Resource

A class representing a dcat:Dataset.

Parameters

identifier (URI) – the identifier of the dataset.

Ref: dcat:Dataset.

property access_rights: str

A link to information about who can access the resource or an indication of its security status.

Type

URI

Return type

str

property access_rights_comments: List[str]

Referanse til hjemmel (kilde for påstand) i offentlighetsloven, sikkerhetsloven, beskyttelsesinstruksen eller annet lovverk som ligger til grunn for vurdering av tilgangsnivå.

Type

List[URI]

Return type

List[str]

property conforms_to: List[str]

A list of links to established standards to which the described resource conforms.

Type

List[URI]

Return type

List[str]

property contactpoint: Contact

Relevant contact information for the cataloged resource.

Type

Contact

Return type

Contact

property creator: str

Link to the entity responsible for producing the resource.

Type

URI

Return type

str

property dct_identifier: str

the identifier for the dataset.

Type

str

Return type

str

property description: Dict[str, str]

A free-text account of the item. key is language code.

Type

Dict[str, str]

Return type

Dict[str, str]

property distributions: List[Distribution]

A list of distributions of the dataset.

Type

List[Distribution]

Return type

List[Distribution]

property frequency: str

A link to resource describing the frequency at which dataset is published.

Type

[URI]

Return type

str

classmethod from_json(json)

Convert a JSON (dict).

Parameters

json (Dict) – A dict representing this class.

Returns

The object.

Return type

Resource

property has_policy: str

A link to an ODRL conformant policy expressing the rights associated with the resource.

Type

URI

Return type

str

property identifier: str

A URI uniquely identifying the resource.

Type

URI

Return type

str

property in_series: DatasetSeries

A dataset series of which the dataset is part.

Type

DatasetSeries]

Return type

DatasetSeries

property is_referenced_by: List[Resource]

A list of related resources, such as a publication, that references, cites, or otherwise points to the cataloged resource.

Type

List[Resource]

Return type

List[Resource]

property keyword: Dict[str, str]

A keyword or tag describing the resource. key is language code.

Type

Dict[str, str]

Return type

Dict[str, str]

property landing_page: List[str]

A list of links to web pages that can be navigated to in a Web browser to gain access to the catalog, a dataset, its distributions and/or additional information.

Type

List[URI]

Return type

List[str]

property language: List[str]

A list of links to languages of the item.

Type

List[str]

Return type

List[str]

property license: str

A link to a legal document under which the resource is made available.

Type

URI

Return type

str

property modification_date: str

Most recent date on which the item was changed, updated or modified.

Type

Date

Return type

str

property prev: Resource

The previous resource in an ordered collection or series of resources.

Type

Resource

Return type

Resource

property publisher: Union[Agent, str]

A URI uniquely identifying the publisher of the resource.

Type

Union[Agent, str]

Return type

Union[Agent, str]

property qualified_attributions: List[Dict]

List of links to an Agent having some form of responsibility for the resource.

Type

List[Dict]

Return type

List[Dict]

property qualified_relation: List[Relationship]

A list of links to a description of a relationship with another resource.

Type

List[Relationship]

Return type

List[Relationship]

property release_date: str

Date of formal issuance (e.g., publication) of the item.

Type

Date

Return type

str

property resource_relation: List[str]

A list of links to resources with an unspecified relationship to the cataloged item.

Type

List[URI]

Return type

List[str]

property rights: str

license or dct:accessRights, such as copyright statements.

Returns

The link

Return type

str

Type

URI

Type

A link to a statement that concerns all rights not addressed with dct

property spatial: List[Union[Location, str]]

A list of geographical areas covered by the dataset.

Type

List[Location]

Return type

List[Union[Location, str]]

property spatial_resolution_in_meters: List[Decimal]

A list of minimum spatial separation resolvables in a dataset, measured in meters.

Type

List[Decimal]

Return type

List[Decimal]

property temporal: List[PeriodOfTime]

A list of temporal periods that the dataset covers.

Type

List[PeriodOfTime]

Return type

List[PeriodOfTime]

property temporal_resolution: List[str]

A list of minimum time period resolvables in the dataset.

Type

List[str]

Return type

List[str]

property theme: List[str]

A list of links to categories of the resource.

Type

List[URI]

Return type

List[str]

property title: Dict[str, str]

A name given to the item. key is langauge code.

Type

Dict[str, str]

Return type

Dict[str, str]

to_json()

Convert the Resource to a json / dict. It will omit the non-initalized fields.

Returns

The json representation of this instance.

Return type

Dict

to_rdf(format='turtle', encoding='utf-8', include_distributions=True)

Maps the catalog to rdf.

Available formats:
  • turtle (default)

  • xml

  • json-ld

Parameters
  • format (str) – a valid format.

  • encoding (str) – the encoding to serialize into

  • include_distributions (bool) – includes the distributions in the graph

Return type

Union[bytes, str]

Returns

a rdf serialization as a bytes literal according to format.

property type_genre: str

A link to the nature or genre of the resource.

Type

URI

Return type

str

property was_generated_by: str

A link to an activity that generated, or provides the business context for, the creation of the dataset.

Type

URI

Return type

str

datacatalogtordf.dataset_series

DatasetSeries module for mapping a dataset_series to rdf.

This module contains methods for mapping a dataset_series object to rdf according to the dcat-ap-no v.2 standard

Example

>>> from datacatalogtordf import Catalog, DatasetSeries, Dataset
>>>
>>> dataset_series = DatasetSeries("http://example.com/dataset_series/1")
>>> dataset_series.title = {"en": "Title of dataset_series"}
>>>
>>> catalog = Catalog("http://example.com/catalog/1")
>>> catalog.datasets.append(dataset_series)
>>>
>>> first_dataset = Dataset()
>>> first_dataset.identifier = "http://example.com/datasets/1"
>>> first_dataset.in_series = dataset_series
>>>
>>> second_dataset = Dataset()
>>> second_dataset.identifier = "http://example.com/datasets/2"
>>> second_dataset.in_series = dataset_series
>>> second_dataset.prev = first_dataset
>>>
>>> dataset_series.first = first_dataset
>>> dataset_series.last = second_dataset
>>>
>>> bool(catalog.to_rdf())
True
class datacatalogtordf.dataset_series.DatasetSeries(identifier=None)

Bases: Dataset

A class representing a dcat:DatasetSeries.

Ref: dcat:DatasetSeries.

Parameters

identifier (URI) – the identifier of the dataset-series.

property access_rights: str

A link to information about who can access the resource or an indication of its security status.

Type

URI

Return type

str

property access_rights_comments: List[str]

Referanse til hjemmel (kilde for påstand) i offentlighetsloven, sikkerhetsloven, beskyttelsesinstruksen eller annet lovverk som ligger til grunn for vurdering av tilgangsnivå.

Type

List[URI]

Return type

List[str]

property conforms_to: List[str]

A list of links to established standards to which the described resource conforms.

Type

List[URI]

Return type

List[str]

property contactpoint: Contact

Relevant contact information for the cataloged resource.

Type

Contact

Return type

Contact

property creator: str

Link to the entity responsible for producing the resource.

Type

URI

Return type

str

property dct_identifier: str

the identifier for the dataset.

Type

str

Return type

str

property description: Dict[str, str]

A free-text account of the item. key is language code.

Type

Dict[str, str]

Return type

Dict[str, str]

property distributions: List[Distribution]

A list of distributions of the dataset.

Type

List[Distribution]

Return type

List[Distribution]

property first: Dataset

The first resource in an ordered collection or series of resources, to which the current resource belongs.

Type

Dataset

Return type

Dataset

property frequency: str

A link to resource describing the frequency at which dataset is published.

Type

[URI]

Return type

str

classmethod from_json(json)

Convert a JSON (dict).

Parameters

json (Dict) – A dict representing this class.

Returns

The object.

Return type

Resource

property has_policy: str

A link to an ODRL conformant policy expressing the rights associated with the resource.

Type

URI

Return type

str

property identifier: str

A URI uniquely identifying the resource.

Type

URI

Return type

str

property in_series: DatasetSeries

A dataset series of which the dataset is part.

Type

DatasetSeries]

Return type

DatasetSeries

property is_referenced_by: List[Resource]

A list of related resources, such as a publication, that references, cites, or otherwise points to the cataloged resource.

Type

List[Resource]

Return type

List[Resource]

property keyword: Dict[str, str]

A keyword or tag describing the resource. key is language code.

Type

Dict[str, str]

Return type

Dict[str, str]

property landing_page: List[str]

A list of links to web pages that can be navigated to in a Web browser to gain access to the catalog, a dataset, its distributions and/or additional information.

Type

List[URI]

Return type

List[str]

property language: List[str]

A list of links to languages of the item.

Type

List[str]

Return type

List[str]

property last: Dataset

The last resource in an ordered collection or series of resources, to which the current resource belongs.

Type

Dataset

Return type

Dataset

property license: str

A link to a legal document under which the resource is made available.

Type

URI

Return type

str

property modification_date: str

Most recent date on which the item was changed, updated or modified.

Type

Date

Return type

str

property prev: Resource

The previous resource in an ordered collection or series of resources.

Type

Resource

Return type

Resource

property publisher: Union[Agent, str]

A URI uniquely identifying the publisher of the resource.

Type

Union[Agent, str]

Return type

Union[Agent, str]

property qualified_attributions: List[Dict]

List of links to an Agent having some form of responsibility for the resource.

Type

List[Dict]

Return type

List[Dict]

property qualified_relation: List[Relationship]

A list of links to a description of a relationship with another resource.

Type

List[Relationship]

Return type

List[Relationship]

property release_date: str

Date of formal issuance (e.g., publication) of the item.

Type

Date

Return type

str

property resource_relation: List[str]

A list of links to resources with an unspecified relationship to the cataloged item.

Type

List[URI]

Return type

List[str]

property rights: str

license or dct:accessRights, such as copyright statements.

Returns

The link

Return type

str

Type

URI

Type

A link to a statement that concerns all rights not addressed with dct

property spatial: List[Union[Location, str]]

A list of geographical areas covered by the dataset.

Type

List[Location]

Return type

List[Union[Location, str]]

property spatial_resolution_in_meters: List[Decimal]

A list of minimum spatial separation resolvables in a dataset, measured in meters.

Type

List[Decimal]

Return type

List[Decimal]

property temporal: List[PeriodOfTime]

A list of temporal periods that the dataset covers.

Type

List[PeriodOfTime]

Return type

List[PeriodOfTime]

property temporal_resolution: List[str]

A list of minimum time period resolvables in the dataset.

Type

List[str]

Return type

List[str]

property theme: List[str]

A list of links to categories of the resource.

Type

List[URI]

Return type

List[str]

property title: Dict[str, str]

A name given to the item. key is langauge code.

Type

Dict[str, str]

Return type

Dict[str, str]

to_json()

Convert the Resource to a json / dict. It will omit the non-initalized fields.

Returns

The json representation of this instance.

Return type

Dict

to_rdf(format='turtle', encoding='utf-8', include_datasets=True, include_services=True, include_models=True, include_contains_services=True)

Maps the catalog to rdf.

Available formats:
  • turtle (default)

  • xml

  • json-ld

Parameters
  • format (str) – a valid format.

  • encoding (str) – the encoding to serialize into

  • include_datasets (bool) – includes the dataset graphs in the catalog

  • include_services (bool) – includes the services in the catalog

  • include_models (bool) – includes the models in the catalog

  • include_contains_services (bool) – includes the services (cpsvno) in the catalog

Return type

Union[bytes, str]

Returns

a rdf serialization as a bytes literal according to format.

property type_genre: str

A link to the nature or genre of the resource.

Type

URI

Return type

str

property was_generated_by: str

A link to an activity that generated, or provides the business context for, the creation of the dataset.

Type

URI

Return type

str

datacatalogtordf.distribution

Distribution module for mapping a distribution to rdf.

This module contains methods for mapping a distribution object to rdf according to the dcat-ap-no v.2 standard

Example

>>> from datacatalogtordf import Distribution
>>>
>>> distribution = Distribution()
>>> distribution.identifier = "http://example.com/dataservices/1"
>>> distribution.title = {"en": "Title of distribution"}
>>>
>>> bool(distribution.to_rdf())
True
class datacatalogtordf.distribution.Distribution(identifier=None)

Bases: object

A class representing a dcat:Distribution.

Ref: dcat:Distribution

Parameters

identifier (URI) – the identifier of the dataset-series.

property access_URL: str

A URL of the resource that gives access to a distribution of the dataset. E.g. landing page, feed, SPARQL endpoint.

Type

URI

Return type

str

property access_rights: str

A link to rights statement that concerns how the distribution is accessed.

Type

URI

Return type

str

property access_service: DataService

A data service that gives access to the distribution of the dataset.

Type

DataService

Return type

DataService

property byte_size: Decimal

The size of a distribution in bytes.

Type

Decimal

Return type

Decimal

property compression_format: str

Link to the compression format of the distribution in which the data is contained in a compressed form, e.g. to reduce the size of the downloadable file.

Type

URI

Return type

str

property conforms_to: List[str]

A list of links to established standards to which the distribution conforms.

Type

List[URI]

Return type

List[str]

property description: Dict[str, str]

A free-text account of the distribution.

Type

Dict[str]

Return type

Dict[str, str]

property download_URL: str

format and/or dcat:mediaType.

Type

URI

Type

The URL of the downloadable file in a given format. E.g. CSV file or RDF file. The format is indicated by the distribution’s dct

Return type

str

property formats: List[str]

A list of file formats of the distribution.

Type

List[URI]

Return type

List[str]

classmethod from_json(json)

Convert a JSON (dict).

Parameters

json (Dict) – A dict representing this class.

Returns

The object.

Return type

Distribution

property has_policy: str

A link to an ODRL conformant policy expressing the rights associated with the distribution.

Type

URI

Return type

str

property identifier: str

A URI uniquely identifying the resource.

Type

URI

Return type

str

property license: str

A link to legal document under which the distribution is made available.

Type

URI

Return type

str

property media_types: List[str]

A list of media types of the distribution as defined by IANA.

Type

List[URI]

Return type

List[str]

property modification_date: str

Most recent date on which the distribution was changed, updated or modified.

Type

Date

Return type

str

property package_format: str

Link to the package format of the distribution in which one or more data files are grouped together, e.g. to enable a set of related files to be downloaded together.

Type

URI

Return type

str

property release_date: str

Date of formal issuance (e.g., publication) of the distribution.

Type

Date

Return type

str

property rights: str

A link to information about rights held in and over the distribution.

Type

URI

Return type

str

property spatial_resolution_in_meters: List[Decimal]

A list of minimum spatial separation resolvables in a dataset distribution, measured in meters.

Type

List[Decimal]

Return type

List[Decimal]

property temporal_resolution: List[str]

A list of minimum time period resolvables in the dataset distribution.

Type

List[str]

Return type

List[str]

property title: Dict[str, str]

A dict with title in multiple languages.

Type

Dict[str]

Return type

Dict[str, str]

to_json()

Convert the Resource to a json / dict. It will omit the non-initalized fields.

Returns

The json representation of this instance.

Return type

Dict

to_rdf(format='turtle', encoding='utf-8')

Maps the distribution to rdf.

Return type

Union[bytes, str]

datacatalogtordf.uri

URI helper module for very basic validation of a uri.

class datacatalogtordf.uri.URI(link)

Bases: str

A helper class to validate a URI.

If the string is serializable as an rdflib.URIRef, it is valid. Otherwise not.

Essentially it is serializable if none of the following chars occurs:

_invalid_uri_chars = '<>" {}|\\^`'
Parameters

link (str) – The string to validate as URI.

Raises

InvalidURIError – If the string is not a valid URI.

Ref: https://github.com/RDFLib/rdflib/blob/master/rdflib/term.py#L75

Example

>>> from datacatalogtordf import Dataset, URI
>>>
>>> dataset = Dataset()
>>> dataset.identifier = URI("http://example.com/datasets/1")
>>> dataset.identifier
'http://example.com/datasets/1'

datacatalogtordf.periodoftime

PeriodOfTime module for mapping a period_of_time to rdf.

This module contains methods for mapping a period_of_time object to rdf according to the dcat-ap-no v.2 standard

Example

>>> from datacatalogtordf import PeriodOfTime
>>>
>>> period_of_time = PeriodOfTime()
>>> period_of_time.start_date = "2019-12-31"
>>> period_of_time.end_date = "2020-12-31"
>>>
>>> bool(period_of_time.to_rdf())
True
class datacatalogtordf.periodoftime.Date(link)

Bases: str

A helper class to validate a Date.

If the string is a valid of the format “%Y-%m-%d”, it is valid. Otherwise not.

Raises

InvalidDateError – If the str does not represent a valid date

class datacatalogtordf.periodoftime.PeriodOfTime

Bases: object

A class representing a dcat:PeriodOfTime.

Ref: dcat:PeriodOfTime

Raises

InvalidDateIntervalError – If the interval is “negative”, i.e. start date is after the end date

property end_date: str

date signfying the end of the period.

Type

str

Return type

str

classmethod from_json(json)

Convert a JSON (dict).

Parameters

json (Dict) – A dict representing this class.

Returns

The object.

Return type

PeriodOfTime

property start_date: str

date signfying the start of the period.

Type

str

Return type

str

to_json()

Convert the Resource to a json / dict. It will omit the non-initalized fields.

Returns

The json representation of this instance.

Return type

Dict

to_rdf(format='turtle', encoding='utf-8')

Maps the period_of_time to rdf.

Return type

Union[bytes, str]

datacatalogtordf.location

Location module for mapping a location to rdf.

This module contains methods for mapping a location object to rdf according to the dcat-ap-no v.2 standard

Example

>>> from datacatalogtordf import Location
>>>
>>> location = Location()
>>> location.identifier = "http://example.com/relations/1"
>>> location.centroid = "POINT(4.88412 52.37509)"
>>>
>>> bool(location.to_rdf())
True
class datacatalogtordf.location.Location(identifier=None)

Bases: object

A class representing a dcat:Location.

Ref: dcat:Location

property bounding_box: str

The geographic bounding box of a resource.

Type

str

Return type

str

property centroid: str

The geographic center (centroid) of a resource.

Type

str

Return type

str

classmethod from_json(json)

Convert a JSON (dict).

Parameters

json (Dict) – A dict representing this class.

Returns

The object.

Return type

Location

property geometry: str

Associates any resource with the corresponding geometry.

Type

str

Return type

str

property identifier: str

an URI uniquely identifying the resource.

Type

URI

Return type

str

to_json()

Convert the Resource to a json / dict. It will omit the non-initalized fields.

Returns

The json representation of this instance.

Return type

Dict

to_rdf(format='turtle', encoding='utf-8')

Maps the location to rdf.

Parameters
  • format (str) – a valid format. Default: turtle

  • encoding (Optional[str]) – the encoding to serialize into

Return type

Union[bytes, str]

Returns

a rdf serialization as a bytes literal according to format.

datacatalogtordf.agent

Agent module for mapping a agent to rdf.

This module contains methods for mapping a agent object to rdf according to the dcat-ap-no v.2 standard

Example

>>> from datacatalogtordf import Agent, Dataset
>>> dataset = Dataset()
>>> dataset.identifier = "http://example.com/datasets/1"
>>> # Create an agent:
>>> agent = Agent()
>>> agent.identifier = "http://example.com/agents/1"
>>> agent.name = {"en": "James Bond", "nb": "Djeims Bånd"}
>>> # Assigen the agent to the publisher property:
>>> dataset.publisher = agent
>>> bool(dataset.to_rdf())
True
class datacatalogtordf.agent.Agent(identifier=None)

Bases: object

A class representing a foaf:Agent.

Parameters

identifier (URI) – the identifier of the dataset.

classmethod from_json(json)

Convert a JSON (dict).

Parameters

json (Dict) – A dict representing this class

Returns

The object

Return type

Agent

property identifier: str

A URI uniquely identifying the agent.

Type

URI

Return type

str

property name: Dict[str, str]

A name given to the agent. key is langauge code.

Type

Dict[str, str]

Return type

Dict[str, str]

property organization_id: str

The organzation’s identifier.

Type

str

Return type

str

property organization_type: str

Link to a concept designating the type of the agent.

Type

URI

Return type

str

property same_as: str

Link to another resource that is the same as this one.

Type

URI

Return type

str

to_json()

Convert the Resource to a json / dict. It will omit the non-initalized fields.

Returns

The json representation of this instance.

Return type

Dict

to_rdf(format='turtle', encoding='utf-8')

Maps the agent to rdf.

Parameters
  • format (str) – a valid format. Default: turtle

  • encoding (Optional[str]) – the encoding to serialize into

Return type

Union[bytes, str]

Returns

a rdf serialization as a bytes literal according to format.

datacatalogtordf.exceptions

Exeptions module for datacatalogtordf.

exception datacatalogtordf.exceptions.Error(msg=None)

Bases: Exception

Base class for exceptions.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception datacatalogtordf.exceptions.InvalidDateError(date, msg)

Bases: Error

Exception raised for errors in the input.

str -- input str in which the error occurred
message -- explanation of the error
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception datacatalogtordf.exceptions.InvalidDateIntervalError(start_date, end_date, msg)

Bases: Error

Exception raised for errors in the input.

str -- input str in which the error occurred
message -- explanation of the error
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.