diff --git a/dev/JSON_to_CPP.py b/dev/JSON_to_CPP.py index 9894cc3a..2546c643 100644 --- a/dev/JSON_to_CPP.py +++ b/dev/JSON_to_CPP.py @@ -2,6 +2,7 @@ import json as pyjson from datetime import datetime import struct import os +import argparse, textwrap # 0: Input file path relative to dev folder # 1: Output file path relative to include folder @@ -18,6 +19,9 @@ def TO_CPP(root_dir): n=1 return [l[i:i+n] for i in range(0, len(l), n)] + # Normalise path name + root_dir = os.path.normpath(root_dir) + # First we package up the JSON files import package_json package_json.package_json(root_dir) @@ -49,4 +53,19 @@ def TO_CPP(root_dir): f.close() if __name__=='__main__': - TO_CPP() \ No newline at end of file + parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, + description=textwrap.dedent("""CoolProp + This program converts the JSON files from dev/fluid etc + to header files. It is necessary to give this program the + value for --path, this is the root directory where + dev/ can be found.""") + ) + + parser.add_argument('--path', required=False, + help='Location of the root folder', + default=None) + + args = parser.parse_args() + + TO_CPP(args.path) \ No newline at end of file diff --git a/dev/generate_headers.py b/dev/generate_headers.py index ab521900..3ed8dfb9 100644 --- a/dev/generate_headers.py +++ b/dev/generate_headers.py @@ -80,7 +80,11 @@ def gitrev_to_file(root_dir): pass if __name__=='__main__': - version_to_file(root_dir = '..') - gitrev_to_file(root_dir = '..') + path = os.path.abspath(__file__) + path = os.path.dirname(path) + path = os.path.dirname(path) + + version_to_file(root_dir = path) + gitrev_to_file(root_dir = path) import JSON_to_CPP - JSON_to_CPP.TO_CPP(root_dir = '..') \ No newline at end of file + JSON_to_CPP.TO_CPP(root_dir = path) \ No newline at end of file