# Path: Grail.py
# class Grail:
#     '''
#     Class that contains functions to generate grail blocks
#     '''
#     filename=""
#     blocks=[]
#     def __init__(self,filename):
#         '''
#         constructor        
#         @param filename: file containing config 
#         @type filename: string
#         '''
#         self.filename=filename
#     def getBlocks(self): 
#         ''' 
#         returns the blocks/sql statements generated by grail
#         '''
#         return self.blocks 
#      
#     def run(self):
#         '''
#         invokes the config parser, generates the sql statements and runs optimizer 
#         '''
#         Parser=ConfigParser(self.filename)
#         config=Parser.configContent
#         translator=Translator(config)
#         translator.translate()
#         self.blocks=translator.getBlocks()
#         #op=Optimizer(translator.getConvertedOptions(),self.blocks,translator.getSenders())
#         #op.run()


from Grail import Grail
import sys, getopt

#!/usr/bin/python


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

# Path: Grail.py
# class Grail:
#     '''
#     Class that contains functions to generate grail blocks
#     '''
#     filename=""
#     blocks=[]
#     def __init__(self,filename):
#         '''
#         constructor        
#         @param filename: file containing config 
#         @type filename: string
#         '''
#         self.filename=filename
#     def getBlocks(self): 
#         ''' 
#         returns the blocks/sql statements generated by grail
#         '''
#         return self.blocks 
#      
#     def run(self):
#         '''
#         invokes the config parser, generates the sql statements and runs optimizer 
#         '''
#         Parser=ConfigParser(self.filename)
#         config=Parser.configContent
#         translator=Translator(config)
#         translator.translate()
#         self.blocks=translator.getBlocks()
#         #op=Optimizer(translator.getConvertedOptions(),self.blocks,translator.getSenders())
#         #op.run()


# Path: Main.py
from Grail import Grail
import sys, getopt


#!/usr/bin/python


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