Skip to content

Commit 1b399b3

Browse files
committed
Update checks and rm commands in hooks: valid plugins are importer and diagnostic (not postprocessor)
This is more consistent with the structure of pysteps which has io/importers postprocessing/diagnostics
1 parent e17a33b commit 1b399b3

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

hooks/post_gen_project.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def remove_file(filepath):
1616

1717
plugin_type = "{{ cookiecutter.plugin_type }}".lower()
1818

19-
if plugin_type == "postprocessor":
20-
shutil.rmtree("{{ cookiecutter.project_slug }}/importer")
21-
else:
22-
shutil.rmtree("{{ cookiecutter.project_slug }}/postprocessor")
19+
VALID_PLUGIN_TYPES = ["importer", "diagnostic", "ensemblestat"]
20+
# Remove the plugin type that was not selected
21+
for plugin in VALID_PLUGIN_TYPES:
22+
if plugin != plugin_type:
23+
shutil.rmtree(f"{{ cookiecutter.project_slug }}/{plugin}")

hooks/pre_gen_project.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
# Exit to cancel project
1414
sys.exit(1)
1515

16+
VALID_PLUGIN_TYPES = ["importer", "diagnostic", "ensemblestat"]
17+
1618
plugin_type = "{{ cookiecutter.plugin_type}}"
17-
if plugin_type != "importer" and plugin_type != "postprocessor":
18-
print('\nERROR: The plugin_type must be "importer" or "postprocessor"')
19-
sys.exit(1)
19+
if plugin_type not in VALID_PLUGIN_TYPES:
20+
print(f'\nERROR: The plugin_type must be one of {", ".join(VALID_PLUGIN_TYPES)}')
21+
sys.exit(1)

0 commit comments

Comments
 (0)