From 8c1f7619cba31fd09244dc595022f9b8d7037a5f Mon Sep 17 00:00:00 2001 From: David Read Date: Tue, 3 Nov 2015 22:08:46 +0000 Subject: [PATCH] Fix code style to be more ckan-like whilst still pep8. --- ckanext/harvest/logic/action/delete.py | 8 +++++--- ckanext/harvest/logic/action/update.py | 3 +-- ckanext/harvest/logic/validators.py | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ckanext/harvest/logic/action/delete.py b/ckanext/harvest/logic/action/delete.py index 17751a4..b2dcfb3 100644 --- a/ckanext/harvest/logic/action/delete.py +++ b/ckanext/harvest/logic/action/delete.py @@ -6,21 +6,23 @@ log = logging.getLogger(__name__) def harvest_source_delete(context, data_dict): - '''Deletes an existing harvest source. + '''Deletes an existing harvest source This method just proxies the request to package_delete, which will delete the actual harvest type dataset and the HarvestSource object (via the after_delete extension point). :param id: the name or id of the harvest source to delete + :type id: string ''' - log.info('Deleting harvest source: %r', data_dict) p.toolkit.check_access('harvest_source_delete', context, data_dict) + p.toolkit.get_action('package_delete')(context, data_dict) + if context.get('clear_source', False): - # We need the id, the name won't work. + # We need the id. The name won't work. package_dict = p.toolkit.get_action('package_show')(context, data_dict) p.toolkit.get_action('harvest_source_clear')( diff --git a/ckanext/harvest/logic/action/update.py b/ckanext/harvest/logic/action/update.py index f8dbaa8..23318bf 100644 --- a/ckanext/harvest/logic/action/update.py +++ b/ckanext/harvest/logic/action/update.py @@ -266,7 +266,6 @@ def harvest_objects_import(context, data_dict): :param package_id: the id or name of the package to import :type package_id: string ''' - log.info('Harvest objects import: %r', data_dict) check_access('harvest_objects_import', context, data_dict) @@ -540,7 +539,7 @@ def harvest_sources_reindex(context, data_dict): @logic.side_effect_free def harvest_source_reindex(context, data_dict): - '''Reindex a single harvest source.''' + '''Reindex a single harvest source''' harvest_source_id = logic.get_or_bust(data_dict, 'id') defer_commit = context.get('defer_commit', False) diff --git a/ckanext/harvest/logic/validators.py b/ckanext/harvest/logic/validators.py index bb1ab12..d8c6a91 100644 --- a/ckanext/harvest/logic/validators.py +++ b/ckanext/harvest/logic/validators.py @@ -60,17 +60,17 @@ def _normalize_url(url): def harvest_source_url_validator(key, data, errors, context): - '''Validate the provided harvest source URL. + '''Validate the provided harvest source URL Checks that the URL is not already existing with the same config. ''' - package = context.get("package") + package = context.get('package') if package: package_id = package.id else: - package_id = data.get(key[:-1] + ("id",)) + package_id = data.get(key[:-1] + ('id',)) try: new_config = data.get(key[:-1] + ('config',))