| 1 |
#! /usr/bin/env autox |
| 2 |
|
| 3 |
import sys |
| 4 |
import os |
| 5 |
from auto.parseC import parseC |
| 6 |
from auto.parseH import parseH |
| 7 |
|
| 8 |
# This is the Python syntax for making a script runnable |
| 9 |
if __name__ == '__main__': |
| 10 |
input = sys.argv[1] |
| 11 |
output = sys.argv[1] |
| 12 |
if len(sys.argv) > 2: |
| 13 |
output = sys.argv[2] |
| 14 |
c=None |
| 15 |
try: |
| 16 |
h=parseH('h.'+input) |
| 17 |
c=parseC() |
| 18 |
except IOError: |
| 19 |
h=None |
| 20 |
try: |
| 21 |
c=parseC('c.'+input) |
| 22 |
except IOError: |
| 23 |
pass |
| 24 |
if h is not None: |
| 25 |
for k,v in h.items(): |
| 26 |
c[k] = v |
| 27 |
elif c is None: |
| 28 |
sys.stderr.write("Neither the c. file nor the h. file exists. Aborting.\n") |
| 29 |
sys.exit(1) |
| 30 |
c.writeFilename('c.'+output,new=True) |
| 31 |
if len(sys.argv) <= 2 and os.path.exists('h.'+sys.argv[1]): |
| 32 |
os.remove('h.'+sys.argv[1]) |