From 4aeec9b9bf9c2f9e4d44888cd5f736f3ca3cb482 Mon Sep 17 00:00:00 2001 From: kovalch Date: Thu, 18 Apr 2024 12:46:09 +0200 Subject: [PATCH] fix: Use excluded_license instead of excluded_rights --- README.md | 6 +++--- ckanext/dcatapchharvest/harvesters.py | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3ad279d..80e9550 100644 --- a/README.md +++ b/README.md @@ -92,11 +92,11 @@ Exclude datasets from import: this will prevent the import of datasets with cert {"excluded_dataset_identifiers":["aaa@oevch", "fahrtprognose@oevch"]} ``` -Exclude resource rights from import: this prevents the import of datasets with certain resource -rights. +Exclude resource license from import: this prevents the import of datasets with certain resource +license. ``` -{"excluded_rights":["NonCommercialWithPermission-CommercialWithPermission-ReferenceRequired"]} +{"excluded_license":["NonCommercialWithPermission-CommercialWithPermission-ReferenceRequired"]} ``` Both configurations only work on the first import. Once imported the harvest diff --git a/ckanext/dcatapchharvest/harvesters.py b/ckanext/dcatapchharvest/harvesters.py index b4cfe2b..611ca34 100644 --- a/ckanext/dcatapchharvest/harvesters.py +++ b/ckanext/dcatapchharvest/harvesters.py @@ -47,14 +47,14 @@ def validate_config(self, source_config): raise ValueError('excluded_dataset_identifiers must be ' 'a list of strings') - if 'excluded_rights' in source_config_obj: - excluded_rights = source_config_obj['excluded_rights'] - if not isinstance(excluded_rights, list): - raise ValueError('excluded_rights must be ' + if 'excluded_license' in source_config_obj: + excluded_license = source_config_obj['excluded_license'] + if not isinstance(excluded_license, list): + raise ValueError('excluded_license must be ' 'a list of strings') if not all(isinstance(item, basestring) - for item in excluded_rights): - raise ValueError('excluded_rights must be ' + for item in excluded_license): + raise ValueError('excluded_license must be ' 'a list of strings') return source_config @@ -143,9 +143,9 @@ def before_create(self, harvest_object, dataset_dict, temp_dict): for excluded_dataset_identifier in source_config_obj.get('excluded_dataset_identifiers', []): # noqa if excluded_dataset_identifier == dataset_dict.get('identifier'): # noqa dataset_dict.clear() - excluded_rights = source_config_obj.get('excluded_rights', []) - dataset_rights = set([res.get('rights') for res in dataset_dict.get('resources', [])]) # noqa - if [rights for rights in dataset_rights if rights in excluded_rights]: # noqa + excluded_license = source_config_obj.get('excluded_license', []) + dataset_license = set([res.get('license') for res in dataset_dict.get('resources', [])]) # noqa + if [license for license in dataset_license if license in excluded_license]: # noqa dataset_dict.clear() except ValueError: pass