Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Some updates
Browse files Browse the repository at this point in the history
  • Loading branch information
koenedaele committed Aug 11, 2016
1 parent 1af27a9 commit eeb3ecb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
0.5.0 (2016-??-??)
0.5.0 (2016-08-12)
------------------

- Make compatible with skosprovider 0.6.x
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# skosprovider==0.6.0
-e git+https://github.com/koenedaele/skosprovider.git#egg=skosprovider
skosprovider==0.6.0
#-e git+https://github.com/koenedaele/skosprovider.git#egg=skosprovider
requests==2.9.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
]

requires = [
'skosprovider',
'skosprovider>=0.6.0',
'requests>=1.0.0'
]

Expand Down
18 changes: 11 additions & 7 deletions skosprovider_oe/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def get_by_id(self, id):
return self.get_by_id(result['use'])
concept = {}
concept['id'] = result['id']
concept['uri'] = result['uri']
concept['type'] = 'concept' if result['term_type'] == 'PT' else 'collection'
concept['labels'] = []
concept['labels'].append(
Expand Down Expand Up @@ -122,14 +123,16 @@ def get_by_id(self, id):
concept['sources'] = []
if 'source_note' in result and result['source_note']:
concept['sources'].append({'citation': result['source_note']})
if concept['type'] == 'concept' and 'matches' in result and result['matches']:
concept['matches'] = result['matches']
return self._from_dict(concept)

def get_by_uri(self, uri):
warnings.warn(
warnings.warn(
'This provider currently does not fully support URIs,\
because the underlying service does not support them and URIs \
have not been decided for these thesauri.',
UserWarning
UserWarning
)
return False

Expand All @@ -145,6 +148,7 @@ def _from_dict(self, concept):
member_of = concept['member_of'] if 'member_of' in concept else [],
notes = concept['notes'] if 'notes' in concept else [],
sources = concept['sources'] if 'sources' in concept else [],
matches = concept['matches'] if 'matches' in concept else {},
concept_scheme = self.concept_scheme
)
else:
Expand Down Expand Up @@ -243,11 +247,11 @@ def get_top_display(self, **kwargs):
hierarchy.
As opposed to the :meth:`get_top_concepts`, this method can possibly
return both concepts and collections.
return both concepts and collections.
:rtype: Returns a list of concepts and collections. For each an
id is present and a label. The label is determined by looking at
the `**kwargs` parameter, the default language of the provider
id is present and a label. The label is determined by looking at
the `**kwargs` parameter, the default language of the provider
and falls back to `en` if nothing is present.
'''
language = self._get_language(**kwargs)
Expand Down Expand Up @@ -276,8 +280,8 @@ def get_children_display(self, id, **kwargs):
:param id: A concept or collection id.
:rtype: A list of concepts and collections. For each an
id is present and a label. The label is determined by looking at
the `**kwargs` parameter, the default language of the provider
and falls back to `en` if nothing is present. If the id does not
the `**kwargs` parameter, the default language of the provider
and falls back to `en` if nothing is present. If the id does not
exist, return `False`.
'''
language = self._get_language(**kwargs)
Expand Down
7 changes: 6 additions & 1 deletion tests/test_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,13 @@ def test_notes(self):

def test_source(self):
romaans = self.stijl.get_by_id(3)
from skosprovider.skos import Source
self.assertIsInstance(romaans.sources, list)
source = 'HASLINGHUIS, E.J. en JANSE, H., Verklarend woordenboek van de westerse architectuur- en bouwhistorie: bouwkundige termen, Leiden, 2005.'
sources = [s.citation for s in romaans.sources]
assert source in sources

def test_matches(self):
agr_ls = self.typologie.get_by_id(2103)
self.assertIsInstance(agr_ls.matches, dict)
assert 'related' in agr_ls.matches
assert 'http://vocab.getty.edu/aat/300008631' in agr_ls.matches['related']

0 comments on commit eeb3ecb

Please sign in to comment.