Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Commit

Permalink
[361] Gemini post-process - tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
David Read committed May 5, 2016
1 parent 4119777 commit 196001f
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions ckanext/dgu/gemini_postprocess.py
Expand Up @@ -13,17 +13,10 @@

from ckan.common import OrderedDict
import ckan.plugins as p
from ckan import logic

log = logging.getLogger(__name__)


def is_id(id_string):
'''Tells the client if the string looks like a revision id or not'''
reg_ex = '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$'
return bool(re.match(reg_ex, id_string))


def hash_a_dict(dict_):
return json.dumps(dict_, sort_keys=True)

Expand All @@ -36,7 +29,8 @@ def process_package_(package_id):
context_ = {'model': model, 'ignore_auth': True, 'session': model.Session,
#'schema': logic.schema.default_show_package_schema()
}
package = p.toolkit.get_action('package_show')(context_, {'id': package_id})
package = p.toolkit.get_action('package_show')(
context_, {'id': package_id})
package_changed = None

# process each resource
Expand All @@ -50,7 +44,8 @@ def process_package_(package_id):
# note if it made a change
if not package_changed:
resource_changed = hash_a_dict(resource) != resource_hash_before
log.info('Resource change: %s %s', resource_changed, resource['url'])
log.info('Resource change: %s %s',
resource_changed, resource['url'])
if resource_changed:
package_changed = True

Expand All @@ -74,17 +69,12 @@ def process_resource(resource):
'''
Edits resource in-place.
'''
#log = process_resource.get_logger()
#load_config(ckan_ini_filepath)
#register_translator()

url = resource['url']

# Check if the service is a view service
is_wms = _is_wms(url)
if is_wms:
#resource['verified'] = True
#resource['verified_date'] = datetime.now().isoformat()
# this no longer sets 'verified' or 'verified_date'
base_urls = _wms_base_urls(url)
resource['wms_base_urls'] = ' '.join(base_urls)
resource['format'] = 'WMS'
Expand Down Expand Up @@ -151,7 +141,8 @@ def _try_wms_url(url, version='1.3'):
Returns:
True - got a WMS response that isn't a ServiceException
False - got a different response, or got HTTP/WMS error
None - socket timeout - host is simply not responding, and is so slow communicating there is no point trying it again
None - socket timeout - host is simply not responding, and is so slow
communicating there is no point trying it again
'''

try:
Expand Down

0 comments on commit 196001f

Please sign in to comment.