Skip to content

Commit dc5186d

Browse files
committed
Decouple harvest model from the rest of the plugin
Separate HarvestMetadataAPIPlugin to its own module, update imports on CLI commands. This CLI would be better off in a separate plugin but we don't want to add more complexity and keep compatibility
1 parent f3e3171 commit dc5186d

File tree

4 files changed

+27
-24
lines changed

4 files changed

+27
-24
lines changed

ckanext/spatial/cli.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# encoding: utf-8
22
import click
33

4-
import ckanext.spatial.util as util
54

65

76
def get_commands():
@@ -22,8 +21,8 @@ def report(pkg):
2221
Performs validation on the harvested metadata, either for all
2322
packages or the one specified.
2423
"""
25-
26-
return util.report(pkg)
24+
from ckanext.spatial.util import report
25+
return report(pkg)
2726

2827

2928
@spatial_validation.command('report-csv')
@@ -33,11 +32,13 @@ def report_csv(filepath):
3332
Performs validation on all the harvested metadata in the db and
3433
writes a report in CSV format to the given filepath.
3534
"""
36-
return util.report_csv(filepath)
35+
from ckanext.spatial.util import report_csv
36+
return report_csv(filepath)
3737

3838

3939
@spatial_validation.command('file')
4040
@click.argument('filepath')
4141
def validate_file(filepath):
4242
"""Performs validation on the given metadata file."""
43-
return util.validate_file(filepath)
43+
from ckanext.spatial.util import validate_file
44+
return validate_file(filepath)

ckanext/spatial/plugin.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from ckan.lib.search import SearchError
1717
from ckan.lib.helpers import json
1818

19-
import ckanext.spatial.views as blueprints
2019
from ckanext.spatial.cli import get_commands
2120
from ckanext.spatial.lib import normalize_bbox
2221
from ckanext.spatial.search import search_backends
@@ -208,20 +207,3 @@ def before_dataset_search(self, search_params):
208207

209208
def get_commands(self):
210209
return get_commands()
211-
212-
213-
class HarvestMetadataApi(p.SingletonPlugin):
214-
'''
215-
Harvest Metadata API
216-
(previously called "InspireApi")
217-
218-
A way for a user to view the harvested metadata XML, either as a raw file or
219-
styled to view in a web browser.
220-
'''
221-
222-
p.implements(p.IBlueprint)
223-
224-
# IBlueprint
225-
226-
def get_blueprint(self):
227-
return [blueprints.harvest_metadata]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from ckan import plugins as p
2+
import ckanext.spatial.views as blueprints
3+
4+
5+
class HarvestMetadataApi(p.SingletonPlugin):
6+
"""
7+
Harvest Metadata API
8+
(previously called "InspireApi")
9+
10+
A way for a user to view the harvested metadata XML, either as a raw file or
11+
styled to view in a web browser.
12+
"""
13+
14+
p.implements(p.IBlueprint)
15+
16+
# IBlueprint
17+
18+
def get_blueprint(self):
19+
return [blueprints.harvest_metadata]

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ dynamic = ["version"]
2828
[project.entry-points."ckan.plugins"]
2929
spatial_metadata = "ckanext.spatial.plugin:SpatialMetadata"
3030
spatial_query = "ckanext.spatial.plugin:SpatialQuery"
31-
spatial_harvest_metadata_api = "ckanext.spatial.plugin:HarvestMetadataApi"
31+
32+
spatial_harvest_metadata_api = "ckanext.spatial.plugin_harvest_metadata_api:HarvestMetadataApi"
3233

3334
csw_harvester = "ckanext.spatial.harvesters:CSWHarvester"
3435
waf_harvester = "ckanext.spatial.harvesters:WAFHarvester"

0 commit comments

Comments
 (0)