aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/gmg_commands/batchaddmedia.py
diff options
context:
space:
mode:
authortilly-Q <nattilypigeonfowl@gmail.com>2014-03-27 14:11:12 -0400
committertilly-Q <nattilypigeonfowl@gmail.com>2014-04-21 12:10:19 -0400
commit8c7cccf6cc6d2a4f58d10a116a535854d6ae9e63 (patch)
treef0d3c98004830d79bb38438cceb1b7fbd6b7f8af /mediagoblin/gmg_commands/batchaddmedia.py
parent26b3d6cf27d8653bfcbd8caf9bec4abfb5c16c5a (diff)
downloadmediagoblin-8c7cccf6cc6d2a4f58d10a116a535854d6ae9e63.tar.lz
mediagoblin-8c7cccf6cc6d2a4f58d10a116a535854d6ae9e63.tar.xz
mediagoblin-8c7cccf6cc6d2a4f58d10a116a535854d6ae9e63.zip
Fixed up some fatal errors. Is still not ready.
Diffstat (limited to 'mediagoblin/gmg_commands/batchaddmedia.py')
-rw-r--r--mediagoblin/gmg_commands/batchaddmedia.py46
1 files changed, 24 insertions, 22 deletions
diff --git a/mediagoblin/gmg_commands/batchaddmedia.py b/mediagoblin/gmg_commands/batchaddmedia.py
index f06bc2e8..414e969c 100644
--- a/mediagoblin/gmg_commands/batchaddmedia.py
+++ b/mediagoblin/gmg_commands/batchaddmedia.py
@@ -138,7 +138,7 @@ zip files and directories"
for media_id in media_locations.keys():
file_metadata = media_metadata[media_id]
- santized_metadata = check_metadata_format(file_metadata)
+ sanitized_metadata = check_metadata_format(file_metadata)
if sanitized_metadata == {}: continue
json_ld_metadata = jsonld.compact(file_metadata, dcterms_context)
@@ -207,7 +207,7 @@ def parse_csv_file(file_contents):
list_of_contents[1:])
objects_dict = {}
- # Build a dictionary
+ # Build a dictionaryfrom mediagoblin.tools.translate import lazy_pass_to_ugettext as _
for line in lines:
if line.isspace() or line == '': continue
values = csv_reader([line]).next()
@@ -228,38 +228,40 @@ def check_metadata_format(metadata_dict):
"$schema":"http://json-schema.org/schema#",
"properties":{
"@context":{},
- "contributor":{},
- "coverage":{},
- "created":{},
- "creator":{},
- "date":{},
- "description":{},
- "format":{},
- "identifier":{},
- "language":{},
- "publisher":{},
- "relation":{},
- "rights" : {
+ "dcterms:contributor":{},
+ "dcterms:coverage":{},
+ "dcterms:created":{},
+ "dcterms:creator":{},
+ "dcterms:date":{},
+ "dcterms:description":{},
+ "dcterms:format":{},
+ "dcterms:identifier":{},
+ "dcterms:language":{},
+ "dcterms:publisher":{},
+ "dcterms:relation":{},
+ "dcterms:rights" : {
"format":"uri",
"type":"string"
},
- "source":{},
- "subject":{},
- "title":{},
- "type":{}
+ "dcterms:source":{},
+ "dcterms:subject":{},
+ "dcterms:title":{},
+ "dcterms:type":{},
+ "media:id":{}
},
"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:
validate(metadata_dict, schema)
output_dict = metadata_dict
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')
print _(
-u"""WARN: Could not find appropriate metadata for file {title}. File will be
-skipped""".format(title=title))
+u"""WARN: Could not find appropriate metadata for file {title}.
+File will be skipped""".format(title=title))
output_dict = {}
except:
raise