42 lines
1.1 KiB
Python
Executable file
42 lines
1.1 KiB
Python
Executable file
#!/usr/bin/python
|
|
#
|
|
import os
|
|
import sys
|
|
import argparse
|
|
|
|
import subprocess as sp
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='Optional app description')
|
|
|
|
# Switch
|
|
parser.add_argument('--overwrite', action='store_true',
|
|
help='write to transport file')
|
|
|
|
parser.add_argument('tranlib',
|
|
help='CHEMKIN transport data file')
|
|
|
|
parser.add_argument('foamTransport',
|
|
help='OpenFOAM transport data file')
|
|
|
|
args = parser.parse_args()
|
|
|
|
print args.overwrite
|
|
|
|
foamTranFile = args.foamTransport
|
|
|
|
tranlibFileName = args.tranlib
|
|
|
|
FNULL = open(os.devnull, 'w')
|
|
|
|
with open(tranlibFileName) as tranlibFile:
|
|
for line in tranlibFile:
|
|
name = line[:19].strip(" ")
|
|
params = "( {} );".format(line[19:70])
|
|
|
|
call_state = sp.call(["foamDictionary", "-entry", name, foamTranFile] , stdout=FNULL, stderr=FNULL)
|
|
|
|
if call_state == 0:
|
|
print "touching ", name, "..."
|
|
sp.check_call(["foamDictionary", "-entry", name+".transport.tranlib", "-set", params, foamTranFile], stdout=FNULL, stderr=FNULL)
|
|
|