Skip to content

Commit

Permalink
change dcat harvester to save resource errors as json
Browse files Browse the repository at this point in the history
  • Loading branch information
joetsoi committed Apr 22, 2015
1 parent e2fb827 commit 93d5950
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions ckanext/sweden/dcat/plugin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import requests

from pylons import config
Expand Down Expand Up @@ -60,22 +61,9 @@ def after_download(self, content, harvest_job):
if response.get('mandatoryError'):
for _class in response['mandatoryError']:
errors.append('Mandatory class {0} missing'.format(_class))

for resource in response.get('resources', []):
for error in resource.get('errors', []):
msg = '[error][{uri}][{type}] {reason} for {path}'
code = error.get('code')
if code == 1 or 'few':
reason = 'Too few values'
elif code == 2 or 'many':
reason = 'Too many values'
else:
reason = ''

errors.append(msg.format(
uri=resource.get('uri'),
type=resource.get('type'),
path=error.get('path'),
reason=reason))
errors.append(json.dumps(resource))

if stop_on_errors:
return None, errors
Expand Down

0 comments on commit 93d5950

Please sign in to comment.