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.
- property conforms_to: List[str]¶
A list of links to established standards to which the described resource conforms.
- property contactpoint: Contact¶
Relevant contact information for the cataloged resource.
- Type
Contact
- Return type
Contact
- classmethod from_json(json)¶
Convert a JSON (dict).
- property has_policy: str¶
A link to an ODRL conformant policy expressing the rights associated with the resource.
- 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.
- 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.
- property modification_date: str¶
Most recent date on which the item was changed, updated or modified.
- property qualified_attributions: List[Dict]¶
List of links to an Agent having some form of responsibility for the resource.
- property qualified_relation: List[Relationship]¶
A list of links to a description of a relationship with another resource.
- Type
List[Relationship]
- Return type
- property resource_relation: List[str]¶
A list of links to resources with an unspecified relationship to the cataloged item.
- 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
- Return type
- 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
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
- 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
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.
- 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å.
- 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
- property catalogs: List[Catalog]¶
A list of catalogs that are of interest in the context of this catalog.
- property conforms_to: List[str]¶
A list of links to established standards to which the described resource conforms.
- property contactpoint: Contact¶
Relevant contact information for the cataloged resource.
- Type
Contact
- Return type
Contact
- property distributions: List[Distribution]¶
A list of distributions of the dataset.
- Type
List[Distribution]
- Return type
- classmethod from_json(json)¶
Convert a JSON (dict).
- property has_policy: str¶
A link to an ODRL conformant policy expressing the rights associated with the resource.
- property in_series: DatasetSeries¶
A dataset series of which the dataset is part.
- Type
- Return type
- 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.
- 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.
- property modification_date: str¶
Most recent date on which the item was changed, updated or modified.
- property qualified_attributions: List[Dict]¶
List of links to an Agent having some form of responsibility for the resource.
- property qualified_relation: List[Relationship]¶
A list of links to a description of a relationship with another resource.
- Type
List[Relationship]
- Return type
- property resource_relation: List[str]¶
A list of links to resources with an unspecified relationship to the cataloged item.
- property services: List[DataService]¶
A list of dataservices of sites or end-points that is listed in the catalog.
- Type
List[DataService]
- Return type
- property spatial_resolution_in_meters: List[Decimal]¶
A list of minimum spatial separation resolvables in a dataset, measured in meters.
- property temporal: List[PeriodOfTime]¶
A list of temporal periods that the dataset covers.
- Type
List[PeriodOfTime]
- Return type
- property themes: List[str]¶
A list of links to knowledge organization system (KOS) used to classify catalog.
- 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
- Return type
- Returns
a rdf serialization as a bytes literal according to format.
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.
- classmethod from_json(json)¶
Convert a JSON (dict).
- Parameters
json (
Dict
) – A dict representing this class.- Returns
The object.
- Return type
- 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
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.
- property conforms_to: List[str]¶
A list of links to established standards to which the described resource conforms.
- property contactpoint: Contact¶
Relevant contact information for the cataloged resource.
- Type
Contact
- Return type
Contact
- property endpointDescription: str¶
A description of the services available via the end-points, including their operations, parameters etc.
- property endpointURL: str¶
The root location or primary endpoint of the service (a Web-resolvable IRI).
- classmethod from_json(json)¶
Convert a JSON (dict).
- property has_policy: str¶
A link to an ODRL conformant policy expressing the rights associated with the resource.
- 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.
- 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.
- property modification_date: str¶
Most recent date on which the item was changed, updated or modified.
- property qualified_attributions: List[Dict]¶
List of links to an Agent having some form of responsibility for the resource.
- property qualified_relation: List[Relationship]¶
A list of links to a description of a relationship with another resource.
- Type
List[Relationship]
- Return type
- property resource_relation: List[str]¶
A list of links to resources with an unspecified relationship to the cataloged item.
- 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
- Return type
- 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
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.
- 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å.
- property conforms_to: List[str]¶
A list of links to established standards to which the described resource conforms.
- property contactpoint: Contact¶
Relevant contact information for the cataloged resource.
- Type
Contact
- Return type
Contact
- property distributions: List[Distribution]¶
A list of distributions of the dataset.
- Type
List[Distribution]
- Return type
- classmethod from_json(json)¶
Convert a JSON (dict).
- property has_policy: str¶
A link to an ODRL conformant policy expressing the rights associated with the resource.
- property in_series: DatasetSeries¶
A dataset series of which the dataset is part.
- Type
- Return type
- 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.
- 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.
- property modification_date: str¶
Most recent date on which the item was changed, updated or modified.
- property qualified_attributions: List[Dict]¶
List of links to an Agent having some form of responsibility for the resource.
- property qualified_relation: List[Relationship]¶
A list of links to a description of a relationship with another resource.
- Type
List[Relationship]
- Return type
- property resource_relation: List[str]¶
A list of links to resources with an unspecified relationship to the cataloged item.
- property spatial_resolution_in_meters: List[Decimal]¶
A list of minimum spatial separation resolvables in a dataset, measured in meters.
- property temporal: List[PeriodOfTime]¶
A list of temporal periods that the dataset covers.
- Type
List[PeriodOfTime]
- Return type
- 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
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.
- 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å.
- property conforms_to: List[str]¶
A list of links to established standards to which the described resource conforms.
- property contactpoint: Contact¶
Relevant contact information for the cataloged resource.
- Type
Contact
- Return type
Contact
- property distributions: List[Distribution]¶
A list of distributions of the dataset.
- Type
List[Distribution]
- Return type
- property first: Dataset¶
The first resource in an ordered collection or series of resources, to which the current resource belongs.
- classmethod from_json(json)¶
Convert a JSON (dict).
- property has_policy: str¶
A link to an ODRL conformant policy expressing the rights associated with the resource.
- property in_series: DatasetSeries¶
A dataset series of which the dataset is part.
- Type
- Return type
- 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.
- 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.
- property last: Dataset¶
The last resource in an ordered collection or series of resources, to which the current resource belongs.
- property modification_date: str¶
Most recent date on which the item was changed, updated or modified.
- property qualified_attributions: List[Dict]¶
List of links to an Agent having some form of responsibility for the resource.
- property qualified_relation: List[Relationship]¶
A list of links to a description of a relationship with another resource.
- Type
List[Relationship]
- Return type
- property resource_relation: List[str]¶
A list of links to resources with an unspecified relationship to the cataloged item.
- property spatial_resolution_in_meters: List[Decimal]¶
A list of minimum spatial separation resolvables in a dataset, measured in meters.
- property temporal: List[PeriodOfTime]¶
A list of temporal periods that the dataset covers.
- Type
List[PeriodOfTime]
- Return type
- 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
- Returns
a rdf serialization as a bytes literal according to format.
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.
- property access_rights: str¶
A link to rights statement that concerns how the distribution is accessed.
- property access_service: DataService¶
A data service that gives access to the distribution of the dataset.
- Type
- Return type
- 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.
- property conforms_to: List[str]¶
A list of links to established standards to which the distribution conforms.
- classmethod from_json(json)¶
Convert a JSON (dict).
- Parameters
json (
Dict
) – A dict representing this class.- Returns
The object.
- Return type
- property has_policy: str¶
A link to an ODRL conformant policy expressing the rights associated with the distribution.
- property modification_date: str¶
Most recent date on which the distribution was changed, updated or modified.
- 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.
- property spatial_resolution_in_meters: List[Decimal]¶
A list of minimum spatial separation resolvables in a dataset distribution, measured in meters.
- property temporal_resolution: List[str]¶
A list of minimum time period resolvables in the dataset distribution.
- 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
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
- classmethod from_json(json)¶
Convert a JSON (dict).
- Parameters
json (
Dict
) – A dict representing this class.- Returns
The object.
- Return type
- 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
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
- classmethod from_json(json)¶
Convert a JSON (dict).
- 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
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).
- 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
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.