Skip to content

Commit

Permalink
Merge branch 'release-0.3.1'
Browse files Browse the repository at this point in the history
* release-0.3.1:
  Update docs.
  Update requirements.
  Update docs to version 0.3.1
  Fix dict_to_thing (#81)
  • Loading branch information
koenedaele committed Feb 19, 2020
2 parents 905630b + c168a04 commit 3bc98f1
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
0.3.1 (2020-02-19)
------------------

- Fix a bug in `dict_to_thing` that resulted in the provider exposing objects
instead of id's in relations. (#80)

0.3.0 (2020-01-24)
------------------

Expand Down
6 changes: 6 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ Utils module

.. automodule:: skosprovider_atramhasis.utils
:members:

Cache_utils module
------------------

.. automodule:: skosprovider_atramhasis.cache_utils
:members:
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
# The short X.Y version.
version = '0.3'
# The full version, including alpha/beta/rc tags.
release = '0.3.0'
release = '0.3.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
12 changes: 6 additions & 6 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

# Documentation
Sphinx==1.8.5 ; python_version < '3.5'
Sphinx==2.2.0 ; python_version >= '3.5'
Sphinx==2.4.2 ; python_version >= '3.5'

# Unit testing
tox==3.14.0
pytest==4.6.6 ; python_version < '3.0'
pytest==5.2.1 ; python_version >= '3.0'
responses==0.10.6
tox==3.14.5
pytest==4.6.9 ; python_version < '3.0'
pytest==5.3.5 ; python_version >= '3.0'
responses==0.10.9
pytest-cov==2.8.1
coveralls==1.8.2
coveralls==1.11.1
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
requests==2.22.0
requests==2.23.0
skosprovider==0.7.0
# -e git+https://github.com/koenedaele/skosprovider.git@DEV_0.7.0#egg=skosprovider
dogpile.cache==0.9.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
]
setup(
name='skosprovider_atramhasis',
version='0.3.0',
version='0.3.1',
description='Skosprovider implementation of Atramhasis Vocabularies',
long_description=README,
long_description_content_type='text/x-rst',
Expand Down
5 changes: 5 additions & 0 deletions skosprovider_atramhasis/cache_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# -*- coding: utf-8 -*-
'''
Utility functions for chaching in :mod:`skosprovider_atramhasis`.
'''

import functools
import json

Expand Down
22 changes: 10 additions & 12 deletions skosprovider_atramhasis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def text_(s, encoding='latin-1', errors='strict'):
def dict_to_thing(dict):
'''
Transform a dict into a
:class:`Concept` or :class:`Collection` .
:class:`skosprovider.skos.Concept` or :class:`skosprovider.skos.Collection` .
If the argument passed is already a :class:`Concept` or :class:`Collection`, this method just
returns the argument.
If the argument passed is already a :class:`skosprovider.skos.Concept` or
:class:`skosprovider.skos.Collection`, this method just returns the argument.
'''
if isinstance(dict, Concept) or isinstance(dict, Collection):
return dict
Expand All @@ -53,7 +53,7 @@ def dict_to_thing(dict):
if type == 'concept':
thing = Concept(id)
if 'subordinate_arrays' in dict:
thing.subordinate_arrays = [(dict_to_thing(n)) for n in dict['subordinate_arrays']]
thing.subordinate_arrays = [n['id'] for n in dict['subordinate_arrays']]
if 'matches' in dict:
matches = dict['matches']
for match_type in thing.matchtypes:
Expand All @@ -62,9 +62,9 @@ def dict_to_thing(dict):
elif type == 'collection':
thing = Collection(id)
if 'superordinates' in dict:
thing.superordinates = [(dict_to_thing(n)) for n in dict['superordinates']]
thing.superordinates = [n['id'] for n in dict['superordinates']]
if 'members' in dict:
thing.members = [(dict_to_thing(n)) for n in dict['members']]
thing.members = [n['id'] for n in dict['members']]
else:
raise ValueError("type: type is not valid ('concept', 'collection') in dict")
thing.type = type
Expand All @@ -77,13 +77,11 @@ def dict_to_thing(dict):
if 'sources' in dict:
thing.sources = [(dict_to_source(n)) for n in dict['sources']]
if 'narrower' in dict:
thing.narrower = [(dict_to_thing(n)) for n in dict['narrower']]
thing.narrower = [n['id'] for n in dict['narrower']]
if 'broader' in dict:
thing.broader = [(dict_to_thing(n)) for n in dict['broader']]
thing.broader = [n['id'] for n in dict['broader']]
if 'related' in dict:
thing.related = [(dict_to_thing(n)) for n in dict['related']]
thing.related = [n['id'] for n in dict['related']]
if 'member_of' in dict:
thing.member_of = [(dict_to_thing(n)) for n in dict['member_of']]
thing.member_of = [n['id'] for n in dict['member_of']]
return thing


3 changes: 3 additions & 0 deletions tests/test_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ def test_get_by_id_concept(self):
assert concept.type == 'concept'
assert len(concept.labels) > 0
assert 'traditioneel' in [l.label for l in concept.labels if l.type == 'prefLabel']
assert 2 in concept.narrower
assert 60 in concept.member_of

@responses.activate
def test_get_by_id_concept_matches(self):
Expand All @@ -234,6 +236,7 @@ def test_get_by_id_concept_matches(self):
assert concept.type == 'concept'
assert len(concept.labels) > 0
assert 'The Chestnut' in [l.label for l in concept.labels if l.type == 'prefLabel']
assert 3 in concept.member_of

@responses.activate
def test_get_by_id_nonexistant_id(self):
Expand Down

0 comments on commit 3bc98f1

Please sign in to comment.