summaryrefslogtreecommitdiff
path: root/tools/trace/tcreator/tcreator.py
blob: be771afb2151ea0eb8dbde438ec45d02729d0774 (plain)
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
import sys
from writer import *

try:
    from lib.parser import *
except:
    print "--> You should run yapps on lib/parser.g"

class TCreator:
        
    def __init__(self, infile, outfile, enum_name = "trace_id_t"):
        self.__infile = infile
        self.__outfile = outfile
        self.__enum_name = enum_name

    def create (self):
        infile = open (self.__infile, 'r')
        data = parse ('parser', infile.read())
        infile.close()

        w = Writer (self.__outfile, self.__enum_name)
        outstring = w.parse_list (data)

        if self.__outfile != "":
            w.write_file (outstring)
        else:
            w.print_file (outstring)