import json
from pprint import pprint
import random
import sys, getopt
import base64
import  tempfile
import argparse
from types import *
import  unicodedata
import jparser

def process(argv):
    #print  argv
    global parser
    parser =  argparse.ArgumentParser(
        description='JamTrack Meta Processing Tool',
        epilog="Note: ")

    parser.add_argument("-D", "--verbosity",
                        help="increase output verbosity",
                        action="store_true")

    parser.add_argument("-i", "--ifile",metavar='JmepScript', type=str,
                    help="The input JMEP script file (.jscr)",required=True,)

    parser.add_argument("-o", "--ofile", metavar='Jmepfile', type=str,
                    help="The output file (.jmep)",required=True,)



    #parser.print_help()
    args = parser.parse_args(argv)
    #print args
    if args.verbosity:
        jparser.DEBUG_ENABLE = 1

    #print args
    jp =  jparser.JmepParser(args.ifile,0,args.ofile)
    if jp.processFile():
        jp.generateJson()
    else:
      sys.exit(1)


    #create json struct from info



if __name__ == "__main__":
   random.seed()
   process(sys.argv[1:])
