UAT_data.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # -*- coding:utf-8 -*-
  2. import os, sys, time
  3. from ssat_sdk.UATree.UAT_excelParser import UATExcelParser
  4. from ssat_sdk.UATree.UAT_fileManage import UATFileManage
  5. from ssat_sdk.UATree.UAT_tree import UATTree
  6. from UAT_log import error,info,debug
  7. DEBUG = True
  8. INFO = True
  9. ERROR = True
  10. class UATData():
  11. cls = "UATData"
  12. def __init__(self):
  13. self.UATree = UATTree()
  14. self.excelParser = UATExcelParser(self.UATree)
  15. self.fileManage = UATFileManage()
  16. treeFileList = self.fileManage.getUATreeList()
  17. for treeFile in treeFileList:
  18. self.addUATExcel(treeFile)
  19. keyCodeFile = self.fileManage.getKeyCodeFile()
  20. self.addKeyCode(keyCodeFile)
  21. '''加载指定的UATree excel表格'''
  22. def addUATExcel(self, excelPath):
  23. self.excelParser.read_excel(excelPath)
  24. '''加载eventkey 键值代码表格'''
  25. def addKeyCode(self, excelPath):
  26. self.excelParser.read_keyCode(excelPath)
  27. '''
  28. 获取parent的完成字典数据
  29. '''
  30. def getParentDict(self, parentName):
  31. return self.UATree.findParentDict(parentName)
  32. '''
  33. 获取指定parent的option列表,option包含所有属性值
  34. :param : parent名字
  35. :return dict:option 字典
  36. '''
  37. def getSubOptionDict(self, parentName):
  38. return self.UATree.getSubOptionDict(parentName)
  39. '''
  40. 获取指定parent的option名字列表
  41. param: parent名字
  42. return: list:option 名字列表
  43. '''
  44. def getSubOptionNames(self, parentName):
  45. optionDict = self.getSubOptionDict(parentName)
  46. return optionDict.keys()
  47. '''
  48. 获取指定option的所有参数
  49. param: option名字
  50. :return option:整个option参数
  51. '''
  52. def getOption(self,optionName):
  53. return self.UATree.findOption(optionName)
  54. '''
  55. 在某一层级获取指定option所有参数
  56. :param targetOption 名字
  57. :param level 所在层级
  58. :return option:整个option参数
  59. '''
  60. def getOpitonInLevel(self,targetOption, level):
  61. return self.UATree.getOpitonInLevel(targetOption, level)
  62. '''
  63. 获取option的parent
  64. '''
  65. def getParentByOption(self, option):
  66. return self.UATree.getParentByOption(option)
  67. '''
  68. 根据当前parent,获取当前
  69. '''
  70. def getPrevParentByParent(self, parent):
  71. return self.UATree.getPrevParent(parent)
  72. '''
  73. 获取指定option的指定参数
  74. :param option名字
  75. :param param
  76. param=optionView
  77. param=move_key
  78. param=enter_key
  79. param=textValue
  80. :return option指定的值
  81. '''
  82. def getOptionParams(self, optionName, param=""):
  83. optionDict = self.getOption(optionName)
  84. if optionDict.has_key(param):
  85. return optionDict[param]
  86. return None
  87. def getTreeDict(self):
  88. return self.UATree.treeDict
  89. def getKeyCodeDict(self):
  90. return self.excelParser.eventKeyCode
  91. if __name__ == "__main__":
  92. uatData = UATData()
  93. print uatData.getOpitonInLevel("usb_picture_1","third")
  94. print uatData.getOpitonInLevel("usb_picture_picture","second")
  95. # print "getParentDict:",uatData.getParentDict("usb_mediaBrowser")
  96. # print "getParentDict:",uatData.getParentDict("usb_device")
  97. # print "getOption:",uatData.getOption("usb_device")
  98. # print "getOption:",uatData.getOption("usb_video_h264-ac3")
  99. # print "getParentDict:",uatData.getParentDict("usb_video_h264-ac3")
  100. # print "getSubOptionDict:",uatData.getSubOptionDict("usb_mediaBrowser")
  101. # print "getSubOptionNames:",uatData.getSubOptionNames("usb_mediaBrowser")
  102. # print "getOption:",uatData.getOption("usb_mediaBrowser")
  103. # print "getOptionParams:",uatData.getOptionParams("usb_device", "enter_key")