PageRenderTime 31ms CodeModel.GetById 22ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/tool_list.py

https://bitbucket.org/h_morita_dbcls/galaxy-central
Python | 68 lines | 64 code | 2 blank | 2 comment | 19 complexity | dfb4c91cb99ae71ffe58533a25929109 MD5 | raw file
 1import os,sys
 2
 3#--------read tool_conf.xml.sample to get all the tool xml file names-----------
 4onoff = 1
 5tool_list = []
 6for 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--------------------------
25name = []
26id = []
27desc = []
28tool_infos = []
29for 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
49flag=0
50if 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"])
58else: 
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"]