From 77d51d4f3378de8f3bbf54dd4c99e62399688800 Mon Sep 17 00:00:00 2001 From: tilly-Q Date: Thu, 3 Apr 2014 12:18:17 -0400 Subject: [PATCH] Fixed a bad get of 'dcterms:rights' and am throwing away the idea of an external context file for the json-ld because it feels unnecessary seeing as we are just using the dc core terms --- mediagoblin/gmg_commands/batchaddmedia.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/mediagoblin/gmg_commands/batchaddmedia.py b/mediagoblin/gmg_commands/batchaddmedia.py index fe345d5f..68993aa2 100644 --- a/mediagoblin/gmg_commands/batchaddmedia.py +++ b/mediagoblin/gmg_commands/batchaddmedia.py @@ -15,7 +15,7 @@ # along with this program. If not, see . import os -import json, tempfile, urllib, tarfile, zipfile, subprocess +import tempfile, urllib, tarfile, zipfile, subprocess from csv import reader as csv_reader from urlparse import urlparse from pyld import jsonld @@ -149,7 +149,7 @@ zip files and directories" title = file_metadata.get('dcterms:title') description = file_metadata.get('dcterms:description') - license = file_metadata.get('dcterms:license') + license = file_metadata.get('dcterms:rights') filename = url.path.split()[-1] if url.scheme == 'http': @@ -201,7 +201,6 @@ FAIL: Local file {filename} could not be accessed.".format(filename=filename) teardown(temp_files) - def parse_csv_file(file_contents): list_of_contents = file_contents.split('\n') key, lines = (list_of_contents[0].split(','), @@ -219,16 +218,16 @@ def parse_csv_file(file_contents): return objects_dict + 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 = { "$schema":"http://json-schema.org/schema#", "properties":{ - "@context":{}, "media:id":{}, "dcterms:contributor":{}, "dcterms:coverage":{}, @@ -250,13 +249,14 @@ def check_metadata_format(metadata_dict): "dcterms:title":{}, "dcterms:type":{} }, - "additionalProperties": false, - "required":["dcterms:title","@context","media:id","bell"] -}""") - metadata_dict["@context"] = u"http://127.0.0.1:6543/metadata_context/v1/" + "additionalProperties": False, + "required":["dcterms:title","media:id"] +} try: validate(metadata_dict, schema) output_dict = metadata_dict + del output_dict['media:id'] + except ValidationError, exc: title = (metadata_dict.get('dcterms:title') or metadata_dict.get('media:id') or _(u'UNKNOWN FILE')) @@ -280,4 +280,5 @@ a "dcterms:title" column for each media file'.format(title=title)) output_dict = {} except: raise + return output_dict -- 2.25.1