-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMain.py
39 lines (31 loc) · 883 Bytes
/
Main.py
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
34
35
36
37
38
39
from Grail import Grail
#!/usr/bin/python
import sys, getopt
def main(argv):
inputfile = ''
outputfile = ''
print inputfile, outputfile
try:
opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="])
except getopt.GetoptError:
print 'test.py -i <inputfile> -o <outputfile>'
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print 'test.py -i <inputfile> -o <outputfile>'
sys.exit()
elif opt in ("-i", "--ifile"):
inputfile = arg
elif opt in ("-o", "--ofile"):
outputfile = arg
grail=Grail(inputfile)
grail.run()
f=open(outputfile,'w')
outputString=""
for block in grail.getBlocks():
ret=block.getBlockSql()
outputString+=ret+"\n"
f.write(outputString)
print "Successflly completed Grail execution. Please check the ouput file for results.\n"
if __name__ == "__main__":
main(sys.argv[1:])