1 | import os,sys |
---|
2 | |
---|
3 | #--------read tool_conf.xml.sample to get all the tool xml file names----------- |
---|
4 | onoff = 1 |
---|
5 | tool_list = [] |
---|
6 | for line in open("tool_conf.xml.sample", "r"): |
---|
7 | if line.find("<!--") != -1: |
---|
8 | onoff = 0 |
---|
9 | if line.find("file") != -1 and onoff==1: |
---|
10 | strs = line.split('\"') |
---|
11 | tool_list.append(strs[1]) |
---|
12 | if line.find("<section") != -1 and onoff==1: |
---|
13 | keys = line.strip().split('\"') |
---|
14 | n = 0 |
---|
15 | strtmp = "section::" |
---|
16 | while n < len(keys) : |
---|
17 | if keys[n].find("id") != -1 : strtmp = strtmp + keys[n+1] |
---|
18 | if keys[n].find("name") != -1 : strtmp = strtmp + keys[n+1] + "-" |
---|
19 | n = n + 1 |
---|
20 | tool_list.append(strtmp.replace(' ', '_')) |
---|
21 | if line.find("-->") != -1: |
---|
22 | onoff =1 |
---|
23 | |
---|
24 | #-------read tool info from every tool xml file-------------------------- |
---|
25 | name = [] |
---|
26 | id = [] |
---|
27 | desc = [] |
---|
28 | tool_infos = [] |
---|
29 | for tool in tool_list : |
---|
30 | if tool.find("section")!=-1 : |
---|
31 | tool_info = dict() |
---|
32 | tool_info["id"] = tool |
---|
33 | tool_infos.append(tool_info) |
---|
34 | if os.path.exists("tools/"+tool) : |
---|
35 | for line in open("tools/"+tool) : |
---|
36 | if line.find("<tool ") != -1 and line.find("id") != -1 : |
---|
37 | keys = line.strip().split('\"') |
---|
38 | n = 0 |
---|
39 | tool_info = dict() |
---|
40 | tool_info["desc"] = '' |
---|
41 | while n < len(keys) : |
---|
42 | if keys[n].find("id") != -1 : tool_info["id"] = keys[n+1].replace(' ', '_') |
---|
43 | if keys[n].find("name") != -1 : tool_info["name"] = keys[n+1] |
---|
44 | if keys[n].find("description") != -1 : tool_info["desc"] = keys[n+1] |
---|
45 | n = n + 1 |
---|
46 | tool_infos.append(tool_info) |
---|
47 | break |
---|
48 | |
---|
49 | flag=0 |
---|
50 | if len(sys.argv) == 1 : |
---|
51 | for tool_info in tool_infos: |
---|
52 | if tool_info["id"].find("section") != -1 : |
---|
53 | print "===========================================================================================================================================" |
---|
54 | print "%-45s\t%-40s\t%s" % ("id", "name", tool_info["id"]) |
---|
55 | print "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" |
---|
56 | else : |
---|
57 | print "%-45s\t%-40s" % (tool_info["id"], tool_info["name"]) |
---|
58 | else: |
---|
59 | for tool_info in tool_infos: |
---|
60 | if tool_info["id"].find("section") != -1 : |
---|
61 | flag=0 |
---|
62 | elif flag==1: |
---|
63 | print " functional.test_toolbox:TestForTool_%s" % tool_info["id"], |
---|
64 | if tool_info["id"].replace('section::', '')==sys.argv[1]: |
---|
65 | flag=1 |
---|
66 | |
---|
67 | #for key in tool_infos.keys(): |
---|
68 | # print tool_infos[key]["id"], "\t", tool_infos[key]["name"], "\t", tool_infos[key]["desc"] |
---|