Skip to content

Commit

Permalink
fix(syntax): flake8;
Browse files Browse the repository at this point in the history
- Syntax fixes from flake8.
  • Loading branch information
JVickery-TBS committed Jan 31, 2024
1 parent 0bc5f9b commit 7fabca4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ckanext/xloader/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

from ckan import plugins
from ckan.plugins import toolkit

from ckan.model.domain_object import DomainObjectOperation
from ckan.model.resource import Resource
from ckan.model.package import Package

from . import action, auth, helpers as xloader_helpers, utils
from ckanext.xloader.utils import XLoaderFormats
Expand Down Expand Up @@ -69,14 +71,15 @@ def configure(self, config_):
# IDomainObjectModification

def notify(self, entity, operation):
# type: (ckan.model.Package|ckan.model.Resource, DomainObjectOperation) -> None
# type: (Package|Resource, DomainObjectOperation) -> None
"""
Runs before_commit to database for Packages and Resources.
We only want to check for changed Resources for this.
We want to check if values have changed, namely the url and the format.
See: ckan/model/modification.py.DomainObjectModificationExtension
"""
if operation != DomainObjectOperation.changed or not isinstance(entity, Resource):
if operation != DomainObjectOperation.changed \
or not isinstance(entity, Resource):
return

context = {
Expand Down Expand Up @@ -206,9 +209,9 @@ def _should_remove_unsupported_resource_from_datastore(res_dict):
return False
return (not XLoaderFormats.is_it_an_xloader_format(res_dict.get('format', u''))
and (res_dict.get('url_type') == 'upload'
or not res_dict.get('url_type'))
or not res_dict.get('url_type'))
and (toolkit.asbool(res_dict.get('datastore_active', False))
or toolkit.asbool(res_dict.get('extras', {}).get('datastore_active', False))))
or toolkit.asbool(res_dict.get('extras', {}).get('datastore_active', False))))


def _remove_unsupported_resource_from_datastore(resource_id):
Expand All @@ -227,7 +230,7 @@ def _remove_unsupported_resource_from_datastore(resource_id):

if _should_remove_unsupported_resource_from_datastore(res):
log.info('Unsupported resource format "%s". Deleting datastore tables for resource %s',
res.get(u'format', u''), res['id'])
res.get(u'format', u''), res['id'])
try:
toolkit.get_action('datastore_delete')(context, {
"resource_id": res['id'],
Expand Down

0 comments on commit 7fabca4

Please sign in to comment.