1
0
mirror of https://github.com/ilri/csv-metadata-quality.git synced 2025-05-10 23:26:01 +02:00

Rework AGROVOC validation

AGROVOC validation is now disabled by default, but can be enabled
on a field-by-field basis. For example, countries and regions are
also present in AGROVOC. Fields with these values can be enabled
using the new `--agrovoc-fields` option.

I reworked the script output to show the field name when printing
an invalid term so that the user knows in which field the term is.
This commit is contained in:
2019-08-01 23:51:58 +03:00
parent 576b3a3638
commit bf876a046a
2 changed files with 12 additions and 5 deletions

View File

@ -186,9 +186,13 @@ def language(field):
return field
def agrovoc(field):
def agrovoc(field, field_name):
"""Check subject terms against AGROVOC REST API.
Function constructor expects the field as well as the field name because
many fields can now be validated against AGROVOC and we want to be able
to inform the user in which field the invalid term is.
Logic copied from agrovoc-lookup.py.
See: https://github.com/ilri/DSpace/blob/5_x-prod/agrovoc-lookup.py
@ -235,6 +239,6 @@ def agrovoc(field):
# check if there are any results
if len(data['results']) == 0:
print(f'Invalid AGROVOC subject: {value}')
print(f'Invalid AGROVOC ({field_name}): {value}')
return field