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
|
#! /usr/bin/env python
import sys
import os
sys.path.append(os.path.join(os.environ["AUTO_DIR"],"python"))
from parseC import parseC
from parseH import parseH
# This is the Python syntax for making a script runnable
if __name__ == '__main__':
input = sys.argv[1]
output = sys.argv[1]
if len(sys.argv) > 2:
output = sys.argv[2]
c=None
try:
h=parseH('h.'+input)
c=parseC()
except IOError:
h=None
try:
c=parseC('c.'+input)
except IOError:
pass
if h is not None:
for k,v in h.items():
c[k] = v
elif c is None:
sys.stderr.write("Neither the c. file nor the h. file exists. Aborting.\n")
sys.exit(1)
c.writeFilename('c.'+output,new=True)
if len(sys.argv) <= 2 and os.path.exists('h.'+sys.argv[1]):
os.remove('h.'+sys.argv[1])
|