From 907d9626e356cfcbc6b3e47a92771650a8eee4e1 Mon Sep 17 00:00:00 2001 From: tilly-Q Date: Thu, 27 Mar 2014 17:29:34 -0400 Subject: [PATCH] Wrote more comprehensive error messages. --- mediagoblin/gmg_commands/batchaddmedia.py | 28 +++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/mediagoblin/gmg_commands/batchaddmedia.py b/mediagoblin/gmg_commands/batchaddmedia.py index 012a5ee4..fe345d5f 100644 --- a/mediagoblin/gmg_commands/batchaddmedia.py +++ b/mediagoblin/gmg_commands/batchaddmedia.py @@ -229,7 +229,7 @@ def check_metadata_format(metadata_dict): "$schema":"http://json-schema.org/schema#", "properties":{ "@context":{}, - + "media:id":{}, "dcterms:contributor":{}, "dcterms:coverage":{}, "dcterms:created":{}, @@ -251,18 +251,32 @@ def check_metadata_format(metadata_dict): "dcterms:type":{} }, "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/" try: validate(metadata_dict, schema) output_dict = metadata_dict except ValidationError, exc: - title = metadata_dict.get('dcterms:title') or metadata_dict.get('media:id') or \ - _(u'UNKNOWN FILE') - print _( -u"""WARN: Could not find appropriate metadata for file "{title}". -File will be skipped""".format(title=title)) + title = (metadata_dict.get('dcterms:title') or + metadata_dict.get('media:id') or _(u'UNKNOWN FILE')) + + if exc.validator == "additionalProperties": + 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 = {} except: raise -- 2.25.1