Skip to content

Commit

Permalink
addresses #24
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalGawor committed Jun 13, 2024
1 parent d244060 commit bdcfd0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion doglib/dtr.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ def get_dtr_taxonomy_by_type(data_type: str) -> dict:
:return: dict, a dictionary representation of the type's taxonomy
"""
dtr_type_search_endpoint = f"http://typeapi.lab.pidconsortium.net/v1/taxonomy/search?query={data_type}&name={data_type}"

try:
url, dtr_taxonomy_search_response, header = get(dtr_type_search_endpoint)
except RequestException as error:
raise DataTypeNotFoundException(f"DataType <{data_type}> doesn't exist in the DTR taxonomy") from error

dtr_taxonomy_json = json.loads(dtr_taxonomy_search_response)

print("get_dtr_taxonomy_by_type: TAXONOMY")
print(dtr_taxonomy_json)
try:
dtr_type_id = dtr_taxonomy_json[0]["id"]
except (IndexError, KeyError) as error:
Expand All @@ -55,6 +57,8 @@ def get_taxonomy_root_node_by_id(data_type_id: str) -> str:
dtr_taxonomy_endpoint = f"http://typeapi.lab.pidconsortium.net/v1/taxonomy/{data_type_id}"
url, dtr_taxonomy_node_response, header = get(dtr_taxonomy_endpoint)
dtr_taxonomy_json = json.loads(dtr_taxonomy_node_response)
print("get_taxonomy_root_node_by_id TAXONOMY:")
print(dtr_taxonomy_json)
try:
dtr_type_id = dtr_taxonomy_json["id"]
except (IndexError, KeyError) as error:
Expand Down
4 changes: 4 additions & 0 deletions doglib/static/repo_configs/VCR.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"url": {"format": "https://collections.clarin.eu/service/v1/collections/$record_id", "regex": ".*/(?P<record_id>[^?;]+).*$", "headers": {
"Accept": "application/x-cmdi+xml"}
},
"doi": {
"id": "10.34733",
"format": "redirect"
},
"parser": {
"type": "cmdi",
"config": {
Expand Down

0 comments on commit bdcfd0d

Please sign in to comment.