diff options
author | tilly-Q <nattilypigeonfowl@gmail.com> | 2014-03-27 13:31:04 -0400 |
---|---|---|
committer | tilly-Q <nattilypigeonfowl@gmail.com> | 2014-04-21 12:10:19 -0400 |
commit | 3e76b2bc7712e012bdb2f971961adf96741e0df3 (patch) | |
tree | 82c1ea355a27e6e68f1dbcdd07639358467f98e7 /mediagoblin/gmg_commands/batchaddmedia.py | |
parent | 5c14f62d19abefb99f392cf1a92b07ec0de26bc4 (diff) | |
download | mediagoblin-3e76b2bc7712e012bdb2f971961adf96741e0df3.tar.lz mediagoblin-3e76b2bc7712e012bdb2f971961adf96741e0df3.tar.xz mediagoblin-3e76b2bc7712e012bdb2f971961adf96741e0df3.zip |
Began work on metadata validation
Diffstat (limited to 'mediagoblin/gmg_commands/batchaddmedia.py')
-rw-r--r-- | mediagoblin/gmg_commands/batchaddmedia.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/mediagoblin/gmg_commands/batchaddmedia.py b/mediagoblin/gmg_commands/batchaddmedia.py index 678c8ab4..83aea7b7 100644 --- a/mediagoblin/gmg_commands/batchaddmedia.py +++ b/mediagoblin/gmg_commands/batchaddmedia.py @@ -26,6 +26,7 @@ from mediagoblin.submit.lib import ( FileUploadLimit, UserUploadLimit, UserPastUploadLimit) from mediagoblin import mg_globals +from jsonschema import validate def parser_setup(subparser): subparser.description = """\ @@ -215,3 +216,35 @@ def parse_csv_file(file_contents): def teardown(temp_files): for temp_file in temp_files: subprocess.call(['rm','-r',temp_file]) + +def check_metadata_format(metadata_dict): + schema = json.loads(""" +{ + "$schema":"http://json-schema.org/schema#", + "properties":{ + "@context":{}, + "contributor":{}, + "coverage":{}, + "created":{}, + "creator":{}, + "date":{}, + "description":{}, + "format":{}, + "identifier":{}, + "language":{}, + "publisher":{}, + "relation":{}, + "rights" : { + "format":"uri", + "type":"string" + }, + "source":{}, + "subject":{}, + "title":{}, + "type":{} + }, + "additionalProperties": false, + "required":["title","@context"] +}""") + try: + validate(metadata_dict, schema) |