#! /usr/bin/env python
-
+#
+# This file is part of libFirm.
+# Copyright (C) 2012 Karlsruhe Institute of Technology.
import sys
import os
import re
keys = "id, " + ", ".join(evcols)
marks = ",".join(['%s'] * (len(evcols)+1))
- self.evinsert = "insert into `%s` values (%s)" % (self.evtab, marks)
+ self.evinsert = "insert into `%s` (%s) values (%s)" % (self.evtab, keys, marks)
keys = ", ".join(ctxcols)
marks = ",".join(['%s'] * len(ctxcols))
evind = 0
ctxcols = dict()
evcols = dict()
+ ctxlist = []
+ evlist = []
linenr = 0
self.valid_keys = set()
key = fields[i]
if not ctxcols.has_key(key):
ctxcols[key] = ctxind
+ ctxlist.append(key)
ctxind += 1
elif fields[0] == 'E':
if not evcols.has_key(key):
self.valid_keys.add(key)
evcols[key] = evind
+ evlist.append(key)
evind += 1
self.ctxcols = ctxcols
self.evcols = evcols
- return (ctxcols, evcols)
+ return (ctxlist, evlist)
def input(self):
return fileinput.FileInput(files=self.files, openhook=fileinput.hook_compressed)
print '%10d / %10d' % (curr_event, self.n_events)
for p in range(1,len(items),2):
- key = items[p]
+ key = items[p]
if key not in self.evcols:
continue
if self.evvals[keyidx] != None:
self.flush_events(self.curr_id)
- value = items[p+1]
+ value = items[p+1]
self.evvals[keyidx] = value
def __init__(self):
- parser = optparse.OptionParser('usage: %prog [options] <event file...>')
- parser.add_option("", "--update", dest="update", help="update database instead of dropping all existing values", action="store_true", default=False)
+ parser = optparse.OptionParser('usage: %prog [options] <event file...>', add_help_option=False)
+ parser.add_option("", "--help", help="show this help message and exit", action="help")
+ parser.add_option("", "--update", dest="update", help="update database instead of dropping all existing values", action="store_true", default=False)
parser.add_option("-v", "--verbose", dest="verbose", help="verbose messages", action="store_true", default=False)
parser.add_option("-f", "--filter", dest="filter", help="regexp to filter event keys", metavar="REGEXP")
parser.add_option("-u", "--user", dest="user", help="user", metavar="USER")