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
40
41
42
43
44
|
#!/usr/bin/python
import sys, os, MYSQLdb
from popen2 import Popen3
LEXER_PATH="."
db = MySQLdb.connect(host = "localhost", user = "sse_web", passwd = "ece6Yoli", db = "sse")
def process_file(root, path):
print "Processing %s" % path
p = Popen3("%s/lex-c %s" % (LEXER_PATH, os.path.join(root, path)))
for identifier in p.fromchild:
print "ID:", identifier.strip()
if p.wait() != 0:
print "WARNING: Subprocess failed!"
del p
def handle_file(root, path, filename):
extension = filename.split(".")[-1]
if extension in ("c", "h"):
process_file(root, os.path.join(path, filename))
def handle_tree(path):
path = os.path.realpath(path)
for dirpath, dirs, files in os.walk(path):
for f in files:
assert path + "/" == (dirpath + "/") [:len(path)+1]
handle_file(path, dirpath[len(path)+1:], f)
for a in sys.argv[1:]:
handle_tree(a)
|