Fixed up some fatal errors. Is still not ready.
This commit is contained in:
parent
26b3d6cf27
commit
8c7cccf6cc
@ -138,7 +138,7 @@ zip files and directories"
|
|||||||
|
|
||||||
for media_id in media_locations.keys():
|
for media_id in media_locations.keys():
|
||||||
file_metadata = media_metadata[media_id]
|
file_metadata = media_metadata[media_id]
|
||||||
santized_metadata = check_metadata_format(file_metadata)
|
sanitized_metadata = check_metadata_format(file_metadata)
|
||||||
if sanitized_metadata == {}: continue
|
if sanitized_metadata == {}: continue
|
||||||
|
|
||||||
json_ld_metadata = jsonld.compact(file_metadata, dcterms_context)
|
json_ld_metadata = jsonld.compact(file_metadata, dcterms_context)
|
||||||
@ -207,7 +207,7 @@ def parse_csv_file(file_contents):
|
|||||||
list_of_contents[1:])
|
list_of_contents[1:])
|
||||||
objects_dict = {}
|
objects_dict = {}
|
||||||
|
|
||||||
# Build a dictionary
|
# Build a dictionaryfrom mediagoblin.tools.translate import lazy_pass_to_ugettext as _
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if line.isspace() or line == '': continue
|
if line.isspace() or line == '': continue
|
||||||
values = csv_reader([line]).next()
|
values = csv_reader([line]).next()
|
||||||
@ -228,38 +228,40 @@ def check_metadata_format(metadata_dict):
|
|||||||
"$schema":"http://json-schema.org/schema#",
|
"$schema":"http://json-schema.org/schema#",
|
||||||
"properties":{
|
"properties":{
|
||||||
"@context":{},
|
"@context":{},
|
||||||
"contributor":{},
|
"dcterms:contributor":{},
|
||||||
"coverage":{},
|
"dcterms:coverage":{},
|
||||||
"created":{},
|
"dcterms:created":{},
|
||||||
"creator":{},
|
"dcterms:creator":{},
|
||||||
"date":{},
|
"dcterms:date":{},
|
||||||
"description":{},
|
"dcterms:description":{},
|
||||||
"format":{},
|
"dcterms:format":{},
|
||||||
"identifier":{},
|
"dcterms:identifier":{},
|
||||||
"language":{},
|
"dcterms:language":{},
|
||||||
"publisher":{},
|
"dcterms:publisher":{},
|
||||||
"relation":{},
|
"dcterms:relation":{},
|
||||||
"rights" : {
|
"dcterms:rights" : {
|
||||||
"format":"uri",
|
"format":"uri",
|
||||||
"type":"string"
|
"type":"string"
|
||||||
},
|
},
|
||||||
"source":{},
|
"dcterms:source":{},
|
||||||
"subject":{},
|
"dcterms:subject":{},
|
||||||
"title":{},
|
"dcterms:title":{},
|
||||||
"type":{}
|
"dcterms:type":{},
|
||||||
|
"media:id":{}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required":["title","@context"]
|
"required":["dcterms:title","@context","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
|
||||||
except ValidationError, exc:
|
except ValidationError, exc:
|
||||||
title = metadata_dict.get('title') or metadata_dict.get('media:id') or \
|
title = metadata_dict.get('dcterms:title') or metadata_dict.get('media:id') or \
|
||||||
_(u'UNKNOWN FILE')
|
_(u'UNKNOWN FILE')
|
||||||
print _(
|
print _(
|
||||||
u"""WARN: Could not find appropriate metadata for file {title}. File will be
|
u"""WARN: Could not find appropriate metadata for file {title}.
|
||||||
skipped""".format(title=title))
|
File will be skipped""".format(title=title))
|
||||||
output_dict = {}
|
output_dict = {}
|
||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
|
Loading…
x
Reference in New Issue
Block a user