diff --git a/pyproject.toml b/pyproject.toml index e5c2f4f..06dc02b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,6 +67,9 @@ windIO = [ Homepage = "https://github.com/IEAWindSystems/windIO" Documentation = "https://ieawindsystems.github.io/windio" +[project.scripts] +windio_converter = "windIO.converters.windIO2windIO:run" + [tool.pytest.ini_options] filterwarnings = [ "error" diff --git a/windIO/converters/windIO2windIO.py b/windIO/converters/windIO2windIO.py old mode 100644 new mode 100755 index 1c52d6d..9bd8f3a --- a/windIO/converters/windIO2windIO.py +++ b/windIO/converters/windIO2windIO.py @@ -1,3 +1,6 @@ +#!/usr/bin/env python +import argparse +import sys import os import traceback from copy import deepcopy @@ -761,18 +764,25 @@ def convert_controls(self, dict_v2p0): return dict_v2p0 - -if __name__ == "__main__": - from pathlib import Path - - turbine_reference_path = Path(windIO.turbine_ex.__file__).parent - - filename_v1p0 = "../../test/turbine/v1p0/IEA-15-240-RWT.yaml" - filename_v2p0 = turbine_reference_path / "IEA-15-240-RWT_v2p0.yaml" +def run(): + parser = argparse.ArgumentParser(description="WindIO v1->v2 Converter") + parser.add_argument("-i", "--input", help="Input v1 filename path") + parser.add_argument("-o", "--output", help="Output v2 filename path") + args = parser.parse_args() + + filename_v1p0 = args.input + filename_v2p0 = args.output if not os.path.exists(filename_v1p0): - raise Exception("Point to an existing yaml file that you want to convert from windIO v1.0 to v2.0.") + raise Exception(f"Cannot find input windIO v1.0 file: {filename_v1p0}.") converter = v1p0_to_v2p0(filename_v1p0, filename_v2p0) converter.convert() + + sys.exit(0) + + +if __name__ == "__main__": + run() +