-
Notifications
You must be signed in to change notification settings - Fork 0
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 #6 from acdh-oeaw/3-configure-zotero-autocomplete-…
…endpoint 3 configure zotero autocomplete endpoint
- Loading branch information
Showing
5 changed files
with
121 additions
and
3 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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
def zotero_description(item_data: dict) -> dict: | ||
item_title = item_data.get('title', 'no title provided') | ||
item_place = item_data.get('place', 'no place provided') | ||
item_date = item_data.get('date', 'no date provided') | ||
item_id = f"#zotero_{item_data['key']}" | ||
item_description = f"{item_title}, {item_place}, {item_date}" | ||
return { | ||
"id": item_id, | ||
"value": item_description | ||
} | ||
|
||
|
||
def populate_zotero_response(data: list, format: str = "teicompleter") -> dict: | ||
if format == 'select2': | ||
result = { | ||
"results": [], | ||
} | ||
for x in data: | ||
item_data = zotero_description(x['data']) | ||
item = { | ||
"id": item_data['id'], | ||
"text": item_data['value'] | ||
} | ||
result['results'].append(item) | ||
return result | ||
|
||
elif format == 'original': | ||
return { | ||
"result": data | ||
} | ||
else: | ||
result = { | ||
"tc:suggestion": [] | ||
} | ||
for x in data: | ||
item_data = zotero_description(x['data']) | ||
item = { | ||
"tc:value": item_data['id'], | ||
"tc:description": item_data['value'] | ||
} | ||
result['tc:suggestion'].append(item) | ||
return result |
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,6 +1,7 @@ | ||
#/bin/bash | ||
|
||
coverage run -m pytest -v | ||
echo "Be aware that we are ignoring warnings, this might come back to you one day!" | ||
coverage run -m pytest -v -p no:warnings | ||
coverage report | ||
coverage html | ||
xdg-open ./htmlcov/index.html |