aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilly-Q <nattilypigeonfowl@gmail.com>2014-04-03 12:18:17 -0400
committertilly-Q <nattilypigeonfowl@gmail.com>2014-04-21 12:10:20 -0400
commit77d51d4f3378de8f3bbf54dd4c99e62399688800 (patch)
tree2df1902b8f513fb28464c5d7016d7f60db2f6c8a
parent907d9626e356cfcbc6b3e47a92771650a8eee4e1 (diff)
downloadmediagoblin-77d51d4f3378de8f3bbf54dd4c99e62399688800.tar.lz
mediagoblin-77d51d4f3378de8f3bbf54dd4c99e62399688800.tar.xz
mediagoblin-77d51d4f3378de8f3bbf54dd4c99e62399688800.zip
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
-rw-r--r--mediagoblin/gmg_commands/batchaddmedia.py21
1 files 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 <http://www.gnu.org/licenses/>.
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