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
This commit is contained in:
parent
907d9626e3
commit
77d51d4f33
@ -15,7 +15,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import json, tempfile, urllib, tarfile, zipfile, subprocess
|
import tempfile, urllib, tarfile, zipfile, subprocess
|
||||||
from csv import reader as csv_reader
|
from csv import reader as csv_reader
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
from pyld import jsonld
|
from pyld import jsonld
|
||||||
@ -149,7 +149,7 @@ zip files and directories"
|
|||||||
|
|
||||||
title = file_metadata.get('dcterms:title')
|
title = file_metadata.get('dcterms:title')
|
||||||
description = file_metadata.get('dcterms:description')
|
description = file_metadata.get('dcterms:description')
|
||||||
license = file_metadata.get('dcterms:license')
|
license = file_metadata.get('dcterms:rights')
|
||||||
filename = url.path.split()[-1]
|
filename = url.path.split()[-1]
|
||||||
|
|
||||||
if url.scheme == 'http':
|
if url.scheme == 'http':
|
||||||
@ -201,7 +201,6 @@ FAIL: Local file {filename} could not be accessed.".format(filename=filename)
|
|||||||
teardown(temp_files)
|
teardown(temp_files)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def parse_csv_file(file_contents):
|
def parse_csv_file(file_contents):
|
||||||
list_of_contents = file_contents.split('\n')
|
list_of_contents = file_contents.split('\n')
|
||||||
key, lines = (list_of_contents[0].split(','),
|
key, lines = (list_of_contents[0].split(','),
|
||||||
@ -219,16 +218,16 @@ def parse_csv_file(file_contents):
|
|||||||
|
|
||||||
return objects_dict
|
return objects_dict
|
||||||
|
|
||||||
|
|
||||||
def teardown(temp_files):
|
def teardown(temp_files):
|
||||||
for temp_file in temp_files:
|
for temp_file in temp_files:
|
||||||
subprocess.call(['rm','-r',temp_file])
|
subprocess.call(['rm','-r',temp_file])
|
||||||
|
|
||||||
|
|
||||||
def check_metadata_format(metadata_dict):
|
def check_metadata_format(metadata_dict):
|
||||||
schema = json.loads("""
|
schema = {
|
||||||
{
|
|
||||||
"$schema":"http://json-schema.org/schema#",
|
"$schema":"http://json-schema.org/schema#",
|
||||||
"properties":{
|
"properties":{
|
||||||
"@context":{},
|
|
||||||
"media:id":{},
|
"media:id":{},
|
||||||
"dcterms:contributor":{},
|
"dcterms:contributor":{},
|
||||||
"dcterms:coverage":{},
|
"dcterms:coverage":{},
|
||||||
@ -250,13 +249,14 @@ def check_metadata_format(metadata_dict):
|
|||||||
"dcterms:title":{},
|
"dcterms:title":{},
|
||||||
"dcterms:type":{}
|
"dcterms:type":{}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": False,
|
||||||
"required":["dcterms:title","@context","media:id","bell"]
|
"required":["dcterms:title","media:id"]
|
||||||
}""")
|
}
|
||||||
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
|
||||||
|
del output_dict['media:id']
|
||||||
|
|
||||||
except ValidationError, exc:
|
except ValidationError, exc:
|
||||||
title = (metadata_dict.get('dcterms:title') or
|
title = (metadata_dict.get('dcterms:title') or
|
||||||
metadata_dict.get('media:id') or _(u'UNKNOWN FILE'))
|
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 = {}
|
output_dict = {}
|
||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
return output_dict
|
return output_dict
|
||||||
|
Loading…
x
Reference in New Issue
Block a user