From 0f951d9fc0d6bb97de96191436d690c14398c674 Mon Sep 17 00:00:00 2001 From: seitenbau-govdata Date: Tue, 15 Nov 2016 22:38:27 +0100 Subject: [PATCH] Improve resolving local groups Improve resolving local groups by searching for group additionally by name. --- ckanext/harvest/harvesters/ckanharvester.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ckanext/harvest/harvesters/ckanharvester.py b/ckanext/harvest/harvesters/ckanharvester.py index 46003e0..1b5a70e 100644 --- a/ckanext/harvest/harvesters/ckanharvester.py +++ b/ckanext/harvest/harvesters/ckanharvester.py @@ -428,8 +428,20 @@ class CKANHarvester(HarvesterBase): for group_ in package_dict['groups']: try: - data_dict = {'id': group_['id']} - group = get_action('group_show')(base_context.copy(), data_dict) + try: + if 'id' in group_: + data_dict = {'id': group_['id']} + group = get_action('group_show')(base_context.copy(), data_dict) + else: + raise NotFound + + except NotFound, e: + if 'name' in group_: + data_dict = {'id': group_['name']} + group = get_action('group_show')(base_context.copy(), data_dict) + else: + raise NotFound + # Found local group validated_groups.append({'id': group['id'], 'name': group['name']}) except NotFound, e: