-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from odissei-data/development
Development
- Loading branch information
Showing
11 changed files
with
71 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,7 @@ celerybeat.pid | |
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Container setup | ||
CONTAINER_NAME=metadata-enhancer | ||
PORT=7070 | ||
APPLICATION_DIR=src | ||
PYTHONPATH: "/root/src/" | ||
|
||
# URL'S | ||
KEYWORD_VOCABULARY_URL='https://fuseki.odissei.nl/skosmos/sparql' | ||
VARIABLE_VOCABULARY_URL='https://fuseki.odissei.nl/skosmos/sparql' | ||
GRLC_API_URL='https://grlc.odissei.nl/api-git/odissei-data/grlc/' | ||
|
||
# Endpoints | ||
KEYWORD_ENDPOINT='matchElsstTermForKeyword' | ||
VARIABLE_ENDPOINT='getCbsVarUri' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,13 @@ | ||
import jmespath | ||
from fastapi import HTTPException | ||
from jmespath.exceptions import JMESPathError | ||
|
||
|
||
def _try_for_key(dictionary: dict, key_path: list, exception_detail: str): | ||
def _try_for_key(dictionary: dict, key_path: str): | ||
""" A function to retrieve a value from a nested dictionary. | ||
The function first sets value equal to dictionary and then loops through | ||
the key_path list, attempting to retrieve the value at each key. | ||
If the value cannot be retrieved due to a KeyError or TypeError, | ||
a HTTPException with a status code of 400 and the provided error message | ||
will be raised. | ||
:param dictionary: A dictionary object to traverse to retrieve a value. | ||
:param key_path: The keys to be traversed to retrieve a value. | ||
:param exception_detail: A string containing a custom error message. | ||
:return: The value at the end of the key path in the dictionary. | ||
""" | ||
value = dictionary | ||
for key in key_path: | ||
try: | ||
value = value[key] | ||
except (KeyError, TypeError): | ||
raise HTTPException(status_code=422, detail=exception_detail) | ||
return value | ||
try: | ||
return jmespath.search(key_path, dictionary) | ||
except JMESPathError as error: | ||
raise HTTPException(status_code=422, detail=str(error)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters