diff --git a/CHANGES.rst b/CHANGES.rst index 6edc960..d66ec8c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,8 +1,7 @@ -0.2.0 (2014-12-??) +0.2.0 (2014-12-19) ------------------ -- Compatibile with `SkosProvider 0.5.0 `_. -- Not backwards compatible with `SkosProvider 0.3.0 `_. +- Compatibile with `SkosProvider 0.5.0 `_. - Each Concept or Collection now also provides information on the ConceptScheme it's part of. - Fix some issues with UTF-8 encoding. diff --git a/docs/source/conf.py b/docs/source/conf.py index d8a3192..8dae404 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -267,5 +267,6 @@ # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { 'python': ('http://docs.python.org/', None), - 'skosprovider': ('http://skosprovider.readthedocs.org/en/latest', None) + 'skosprovider': ('http://skosprovider.readthedocs.org/en/latest', None), + 'rdflib': ('http://rdflib.readthedocs.org/en/latest', None) } diff --git a/docs/source/index.rst b/docs/source/index.rst index 21a0b15..49fb13c 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -4,7 +4,7 @@ contain the root `toctree` directive. Welcome to skosprovider_heritagedata's documentation! -============================================== +===================================================== .. toctree:: :maxdepth: 2 diff --git a/requirements.txt b/requirements.txt index f2002e4..0fe28d2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -requests==2.4.1 -#skosprovider==0.5.0 --e git+https://github.com/koenedaele/skosprovider.git#egg=skosprovider +requests==2.5.0 +skosprovider==0.5.0 +#-e git+https://github.com/koenedaele/skosprovider.git#egg=skosprovider rdflib==4.1.2 diff --git a/setup.py b/setup.py index 0ef78fb..debe69d 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ ] requires = [ - 'skosprovider', + 'skosprovider>=0.5.0', 'requests', 'rdflib' ] @@ -40,6 +40,6 @@ author='Flanders Heritage Agency', author_email='ict@onroerenderfgoed.be', url='https://github.com/OnroerendErfgoed/skosprovider_heritagedata', - keywords='heritagedata.org skos skosprovider', + keywords='heritagedata.org skos skosprovider thesauri vocabularies', test_suite='nose.collector' ) diff --git a/skosprovider_heritagedata/providers.py b/skosprovider_heritagedata/providers.py index dee0473..e6e7253 100644 --- a/skosprovider_heritagedata/providers.py +++ b/skosprovider_heritagedata/providers.py @@ -5,14 +5,18 @@ ''' import requests +from requests.exceptions import ConnectionError + import warnings import logging -from requests.exceptions import ConnectionError log = logging.getLogger(__name__) + from language_tags import tags from rdflib.namespace import SKOS + from skosprovider.exceptions import ProviderUnavailableException from skosprovider.providers import VocabularyProvider + from skosprovider_heritagedata.utils import ( _split_uri, uri_to_graph, @@ -281,4 +285,4 @@ def _get_items(self, service, params): d[uri] = item elif tags.tag(item['lang']).format == 'en': d[uri] = item - return list(d.values()) \ No newline at end of file + return list(d.values()) diff --git a/skosprovider_heritagedata/utils.py b/skosprovider_heritagedata/utils.py index 2b6a13a..3d1bd11 100644 --- a/skosprovider_heritagedata/utils.py +++ b/skosprovider_heritagedata/utils.py @@ -3,21 +3,19 @@ Utility functions for :mod:`skosprovider_heritagedata`. ''' -import rdflib -from rdflib.term import URIRef import requests - from skosprovider.skos import ( Concept, Label, Note, ConceptScheme) - from skosprovider.exceptions import ProviderUnavailableException import logging import sys +log = logging.getLogger(__name__) + PY3 = sys.version_info[0] == 3 if PY3: # pragma: no cover @@ -25,13 +23,19 @@ else: # pragma: no cover binary_type = str -log = logging.getLogger(__name__) - +import rdflib +from rdflib.term import URIRef from rdflib.namespace import RDF, SKOS, DC, RDFS PROV = rdflib.Namespace('http://www.w3.org/ns/prov#') def conceptscheme_from_uri(conceptscheme_uri): + ''' + Read a SKOS Conceptscheme from a :term:`URI` + + :param string conceptscheme_uri: URI of the conceptscheme. + :rtype: skosprovider.skos.ConceptScheme + ''' graph = uri_to_graph('%s.rdf' % (conceptscheme_uri)) # get the conceptscheme @@ -46,6 +50,14 @@ def conceptscheme_from_uri(conceptscheme_uri): def things_from_graph(graph, concept_scheme): + ''' + Read concepts and collections from a graph. + + :param rdflib.Graph graph: Graph to read from. + :param skosprovider.skos.ConceptScheme concept_scheme: Conceptscheme the + concepts and collections belong to. + :rtype: :class:`list` + ''' clist = [] for sub, pred, obj in graph.triples((None, RDF.type, SKOS.Concept)): uri = str(sub)