Merge pull request #25 from Rod-Persky/python-args

Added parameter for path to JSON_to_CPP.py
This commit is contained in:
Jorrit Wronski
2014-05-16 09:13:22 +02:00
2 changed files with 27 additions and 4 deletions

View File

@@ -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()
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)

View File

@@ -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 = '..')
JSON_to_CPP.TO_CPP(root_dir = path)