Skip to content

Commit 13e4e09

Browse files
author
Felix Erdmann
committed
Match expected naming as expected in pysteps repo
- added plugin_function as parameter (needed for importer plugins) - updated setup script for entry_points - updated function names
1 parent 282a307 commit 13e4e09

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

cookiecutter.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"project_name": "{{ 'pysteps-' + cookiecutter.plugin_type + '-' + cookiecutter.plugin_subtype + '-name' }}",
77
"project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_') }}",
88
"plugin_name": "{{ cookiecutter.project_slug.split('_', 1)[1] }}",
9+
"plugin_function": "{{ cookiecutter.plugin_name.replace('importer', 'import') }}",
910
"project_short_description": "Pysteps plugin adding x functionality",
1011
"version": "0.1.0",
1112
"open_source_license": ["MIT license", "BSD license", "ISC license", "GNU General Public License v3", "Apache Software License 2.0", "Not open source"]

{{cookiecutter.project_name}}/setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@
2525

2626
entry_label = 'pysteps.plugins.' + '{{ cookiecutter.plugin_type }}'
2727

28+
# It woudld be even better to read the functions from the plugin module.
29+
# We could add multiple functions in the entry_points.
30+
# Is that possible?
31+
# e.g. like plugin_functions = [attr for attr in dir(importlib.import_module(cookiecutter.project_slug.cookiecutter.plugin_type.cookiecutter.plugin_name)) if attr.startswith("import_" if "importer" in cookiecutter.plugin_type else cookiecutter.plugin_type+"_")]
32+
# Then loop over the functions to set all entry_points.
2833
entry = {
2934
entry_label: [
30-
'{{ cookiecutter.plugin_name }}={{ cookiecutter.project_slug }}.{{ cookiecutter.plugin_type }}.{{ cookiecutter.plugin_name }}:{{cookiecutter.plugin_name }}'
35+
'{{ cookiecutter.plugin_function }}={{ cookiecutter.project_slug }}.{{ cookiecutter.plugin_type }}.{{ cookiecutter.plugin_name }}:{{ cookiecutter.plugin_function }}'
3136
]
3237
}
3338

{{cookiecutter.project_name}}/{{cookiecutter.project_slug}}/diagnostic/{{cookiecutter.plugin_name}}.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
#
5454
#
5555

56-
def {{cookiecutter.plugin_name}}(filename, **kwargs):
56+
def {{cookiecutter.plugin_function}}(filename, **kwargs):
5757
"""
5858
A detailed description of the postprocessing plugin. A minimal documentation is
5959
strictly needed since the pysteps postprocessing interface expects docstrings.

{{cookiecutter.project_name}}/{{cookiecutter.project_slug}}/importer/{{cookiecutter.plugin_name}}.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
#
8282
#
8383
@postprocess_import()
84-
def import_abc_xxx(filename, keyword1="some_keyword", keyword2=10, **kwargs):
84+
def {{cookiecutter.plugin_function}}(filename, keyword1="some_keyword", keyword2=10, **kwargs):
8585
"""
8686
A detailed description of the importer. A minimal documentation is
8787
strictly needed since the pysteps importers interface expect docstrings.

0 commit comments

Comments
 (0)