/tool_list.py

https://bitbucket.org/h_morita_dbcls/galaxy-central · Python · 68 lines · 60 code · 4 blank · 4 comment · 29 complexity · dfb4c91cb99ae71ffe58533a25929109 MD5 · raw file

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