# -*- coding:utf-8 -*- import os, sys, time from ssat_sdk.UATree.UAT_excelParser import UATExcelParser from ssat_sdk.UATree.UAT_fileManage import UATFileManage from ssat_sdk.UATree.UAT_tree import UATTree from UAT_log import error,info,debug DEBUG = True INFO = True ERROR = True class UATData(): cls = "UATData" def __init__(self): self.UATree = UATTree() self.excelParser = UATExcelParser(self.UATree) self.fileManage = UATFileManage() treeFileList = self.fileManage.getUATreeList() for treeFile in treeFileList: self.addUATExcel(treeFile) keyCodeFile = self.fileManage.getKeyCodeFile() self.addKeyCode(keyCodeFile) '''加载指定的UATree excel表格''' def addUATExcel(self, excelPath): self.excelParser.read_excel(excelPath) '''加载eventkey 键值代码表格''' def addKeyCode(self, excelPath): self.excelParser.read_keyCode(excelPath) ''' 获取parent的完成字典数据 ''' def getParentDict(self, parentName): return self.UATree.findParentDict(parentName) ''' 获取指定parent的option列表,option包含所有属性值 :param : parent名字 :return dict:option 字典 ''' def getSubOptionDict(self, parentName): return self.UATree.getSubOptionDict(parentName) ''' 获取指定parent的option名字列表 param: parent名字 return: list:option 名字列表 ''' def getSubOptionNames(self, parentName): optionDict = self.getSubOptionDict(parentName) return optionDict.keys() ''' 获取指定option的所有参数 param: option名字 :return option:整个option参数 ''' def getOption(self,optionName): return self.UATree.findOption(optionName) ''' 在某一层级获取指定option所有参数 :param targetOption 名字 :param level 所在层级 :return option:整个option参数 ''' def getOpitonInLevel(self,targetOption, level): return self.UATree.getOpitonInLevel(targetOption, level) ''' 获取option的parent ''' def getParentByOption(self, option): return self.UATree.getParentByOption(option) ''' 根据当前parent,获取当前 ''' def getPrevParentByParent(self, parent): return self.UATree.getPrevParent(parent) ''' 获取指定option的指定参数 :param option名字 :param param param=optionView param=move_key param=enter_key param=textValue :return option指定的值 ''' def getOptionParams(self, optionName, param=""): optionDict = self.getOption(optionName) if optionDict.has_key(param): return optionDict[param] return None def getTreeDict(self): return self.UATree.treeDict def getKeyCodeDict(self): return self.excelParser.eventKeyCode if __name__ == "__main__": uatData = UATData() print uatData.getOpitonInLevel("usb_picture_1","third") print uatData.getOpitonInLevel("usb_picture_picture","second") # print "getParentDict:",uatData.getParentDict("usb_mediaBrowser") # print "getParentDict:",uatData.getParentDict("usb_device") # print "getOption:",uatData.getOption("usb_device") # print "getOption:",uatData.getOption("usb_video_h264-ac3") # print "getParentDict:",uatData.getParentDict("usb_video_h264-ac3") # print "getSubOptionDict:",uatData.getSubOptionDict("usb_mediaBrowser") # print "getSubOptionNames:",uatData.getSubOptionNames("usb_mediaBrowser") # print "getOption:",uatData.getOption("usb_mediaBrowser") # print "getOptionParams:",uatData.getOptionParams("usb_device", "enter_key")