Skip to content

Commit

Permalink
fix: Use excluded_license instead of excluded_rights
Browse files Browse the repository at this point in the history
  • Loading branch information
kovalch committed Apr 18, 2024
1 parent 21747d5 commit 4aeec9b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions ckanext/dcatapchharvest/harvesters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4aeec9b

Please sign in to comment.