-
Notifications
You must be signed in to change notification settings - Fork 0
/
ices_erf32_generator_cli.py
52 lines (45 loc) · 1.53 KB
/
ices_erf32_generator_cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python3
# -*- coding:utf-8 -*-
#
# Copyright (c) 2021-present SMHI, Swedish Meteorological and Hydrological Institute
# License: MIT License (see LICENSE.txt or http://opensource.org/licenses/mit).
import pathlib
import click
import ices_erf32_generator_main
global ices_config
@click.command()
@click.option(
"--row",
default=0,
prompt="Execute row",
help="Row number used to select which YAML-file to generate ICES-Erf32 from.",
)
def run_erf32_generator_command(row):
""" """
global ices_erf32_config
if (row < 0) or (row > len(ices_erf32_config)):
print("\n\nERROR: Wrong value. Please try again.\n\n")
return
generator = ices_erf32_generator_main.IcesErf32Generator()
if row == 0:
for config_file in ices_erf32_config:
generator.generate_erf32(config_file)
else:
generator.generate_erf32(ices_erf32_config[row - 1])
if __name__ == "__main__":
""" """
global ices_erf32_config
ices_erf32_config = []
for file_path in pathlib.Path("erf32_config").glob("ices_erf32_*.yaml"):
ices_erf32_config.append(str(file_path))
ices_erf32_config = sorted(ices_erf32_config)
# Print before command.
print("\n\nICES ERF 3.2 generator.")
print("-----------------------------")
print("Select row number. Press enter to run all.")
print("Press Ctrl-C to terminate.\n")
for index, row in enumerate(ices_erf32_config):
print(index + 1, " ", row)
print("")
# Execute command.
run_erf32_generator_command()