Wrote more comprehensive error messages.
This commit is contained in:
parent
32aec1e533
commit
0e4144abaf
@ -229,7 +229,7 @@ def check_metadata_format(metadata_dict):
|
|||||||
"$schema":"http://json-schema.org/schema#",
|
"$schema":"http://json-schema.org/schema#",
|
||||||
"properties":{
|
"properties":{
|
||||||
"@context":{},
|
"@context":{},
|
||||||
|
"media:id":{},
|
||||||
"dcterms:contributor":{},
|
"dcterms:contributor":{},
|
||||||
"dcterms:coverage":{},
|
"dcterms:coverage":{},
|
||||||
"dcterms:created":{},
|
"dcterms:created":{},
|
||||||
@ -251,18 +251,32 @@ def check_metadata_format(metadata_dict):
|
|||||||
"dcterms:type":{}
|
"dcterms:type":{}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required":["dcterms:title","@context","media:id"]
|
"required":["dcterms:title","@context","media:id","bell"]
|
||||||
}""")
|
}""")
|
||||||
metadata_dict["@context"] = u"http://127.0.0.1:6543/metadata_context/v1/"
|
metadata_dict["@context"] = u"http://127.0.0.1:6543/metadata_context/v1/"
|
||||||
try:
|
try:
|
||||||
validate(metadata_dict, schema)
|
validate(metadata_dict, schema)
|
||||||
output_dict = metadata_dict
|
output_dict = metadata_dict
|
||||||
except ValidationError, exc:
|
except ValidationError, exc:
|
||||||
title = metadata_dict.get('dcterms:title') or metadata_dict.get('media:id') or \
|
title = (metadata_dict.get('dcterms:title') or
|
||||||
_(u'UNKNOWN FILE')
|
metadata_dict.get('media:id') or _(u'UNKNOWN FILE'))
|
||||||
print _(
|
|
||||||
u"""WARN: Could not find appropriate metadata for file "{title}".
|
if exc.validator == "additionalProperties":
|
||||||
File will be skipped""".format(title=title))
|
message = _(u'Invalid metadata provided for file "{title}". This \
|
||||||
|
script only accepts the Dublin Core metadata terms.'.format(title=title))
|
||||||
|
|
||||||
|
elif exc.validator == "required":
|
||||||
|
message = _(
|
||||||
|
u'All necessary metadata was not provided for file "{title}", you must include \
|
||||||
|
a "dcterms:title" column for each media file'.format(title=title))
|
||||||
|
|
||||||
|
else:
|
||||||
|
message = _(u'Could not find appropriate metadata for file \
|
||||||
|
"{title}".'.format(title=title))
|
||||||
|
|
||||||
|
print _(u"""WARN: {message} \nSkipping File...\n""".format(
|
||||||
|
message=message))
|
||||||
|
|
||||||
output_dict = {}
|
output_dict = {}
|
||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
|
Loading…
x
Reference in New Issue
Block a user