Skip to content
Snippets Groups Projects
Commit 7a3cbb89 authored by anonymous's avatar anonymous
Browse files

refactors name of Statistikamt Nord harvester

parent 7dd4366c
No related branches found
No related tags found
No related merge requests found
......@@ -46,6 +46,7 @@ class Initialization(CkanCommand):
ckan_api_client = ckanapi.LocalCKAN()
self._handle_organizations(ckan_api_client)
self._handle_harvesters(ckan_api_client)
def _handle_organizations(self, ckan_api_client):
present_orgs_dict = ckan_api_client.action.organization_list()
......@@ -76,19 +77,61 @@ class Initialization(CkanCommand):
group_dict
)
else:
skip_message = 'Skipping creation of group '
skip_message = 'Skipping creation of organization '
skip_message = skip_message + "{org_key}, as it's already present."
print(skip_message.format(org_key=org_key))
def _handle_harvesters(self, ckan_api_client):
data_dict = {}
harvesters = get_action('harvest_source_list')(self.create_context_with_user(), data_dict)
present_harvesters_list = list()
for harvester in harvesters:
present_harvesters_list.append(harvester["title"])
odsh_harvesters = {
"Kiel": {
'name': "Kiel",
'url': "https://www.kiel.de/de/kiel_zukunft/statistik_kieler_zahlen/open_data/Kiel_open_data.json",
'source_type': "kiel",
'title': "Kiel",
'active': True,
'owner_org': "kiel",
'frequency': "MANUAL"
},
"Statistikamt-Nord": {
'name': "Statistikamt-Nord",
'url': "file:///usr/lib/ckan/default/src/statistik-nord-stripped.xml",
'source_type': "statistikamt-nord",
'title': "Statistik-Nord",
'active': True,
'owner_org': "statistikamt",
'frequency': "MANUAL"
}
}
for harvester_key in odsh_harvesters:
if harvester_key not in present_harvesters_list:
add_message = 'Adding harvester {harvester_key}.'.format(
harvester_key=harvester_key
)
print(add_message)
harvester_dict = odsh_harvesters[harvester_key]
get_action('harvester_source_create')(self.create_context_with_user(), harvester_dict)
else:
skip_message = 'Skipping creation of harvester '
skip_message = skip_message + "{harvester_key}, as it's already present."
print(skip_message.format(harvester_key=harvester_key))
def _create_and_purge_organization(self, organization_dict):
"""Worker method for the actual group addition.
For unpurged groups a purge happens prior."""
"""Worker method for the actual organization addition.
For unpurged organizations a purge happens prior."""
try:
get_action('organization_purge')(self.create_context_with_user(), organization_dict)
except NotFound:
not_found_message = 'Group {group_name} not found, nothing to purge.'.format(
group_name=organization_dict['name']
not_found_message = 'Organization {organization_name} not found, nothing to purge.'.format(
organization_name=organization_dict['name']
)
print(not_found_message)
finally:
......
......@@ -6,5 +6,5 @@ except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
from ckanext.odsh.harvesters.statistiknordharvester import StatistikNordHarvester
from ckanext.odsh.harvesters.statistiknordharvester import StatistikamtNordHarvester
from ckanext.odsh.harvesters.kielharvester import KielHarvester
......@@ -26,15 +26,15 @@ from ckanext.odsh.harvesters.ckan_mapper import pyjq_mapper
log = logging.getLogger(__name__)
class StatistikNordHarvester(HarvesterBase):
class StatistikamtNordHarvester(HarvesterBase):
"""
A Harvester for Statistikamt Nord
"""
def info(self):
return {
'name': 'statistik-nord',
'title': 'Statistik Nord',
'name': 'statistikamt-nord',
'title': 'Statistikamt Nord',
'description': 'Harvests Statistikamt Nord',
'form_config_interface': 'Text'
}
......
......@@ -81,7 +81,7 @@ setup(
entry_points='''
[ckan.plugins]
odsh=ckanext.odsh.plugin:OdshPlugin
statistiknord_harvester=ckanext.odsh.harvesters:StatistikNordHarvester
statistikamtnord_harvester=ckanext.odsh.harvesters:StatistikamtNordHarvester
kiel_harvester=ckanext.odsh.harvesters:KielHarvester
[paste.paster_command]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment