Option.py 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. # -*- coding:utf-8 -*-
  2. """
  3. 注:私有变量和函数,前面加双下划线(不要在后面也加双下划线);
  4. """
  5. import os
  6. import sys
  7. import time
  8. # 使用inspect模块动态获取当前运行的函数名
  9. import inspect
  10. # 日期头文件;
  11. from datetime import datetime
  12. # 自动化sdk头;
  13. from ssat_sdk.sat_environment import getMenuTree3SelectedPExcelPath
  14. from ssat_sdk.sat_environment import getMenuTree3SelectedProjectCfgPath
  15. from ssat_sdk.sat_environment import getMenuTree3SelectedTvExcelPath
  16. from ssat_sdk.sat_environment import getMenuTreeSelectedChannel
  17. # 获取运行函数名;
  18. def get_fun_name():
  19. return inspect.stack()[1][3]
  20. # 日志基类;
  21. class CBaseLog:
  22. def __init__(self):
  23. pass
  24. def __printlog(self, msg):
  25. # 时间/内容;
  26. print("%s %s") % (datetime.now().strftime('%Y-%m-%d %H:%M:%S'), msg)
  27. def debug(self, fun, msg):
  28. # 类型/类名:函数/内容
  29. log_str = "【DEBUG】<%s::%s> %s" % (self.__class__.__name__, fun, msg)
  30. self.__printlog(log_str)
  31. def info(self, fun, msg):
  32. # 类型/类名:函数/内容
  33. log_str = "【INFO】<%s::%s> %s" % (self.__class__.__name__, fun, msg)
  34. self.__printlog(log_str)
  35. def warn(self, fun, msg):
  36. # 类型/类名:函数/内容
  37. log_str = "【WARN】<%s::%s> %s" % (self.__class__.__name__, fun, msg)
  38. self.__printlog(log_str)
  39. def error(self, fun, msg):
  40. # 类型/类名:函数/内容
  41. log_str = "【ERROR】<%s::%s> %s" % (self.__class__.__name__, fun, msg)
  42. self.__printlog(log_str)
  43. def log(self, msg):
  44. # 类型/类名/内容
  45. log_str = "【LOG】<%s> %s" % (self.__class__.__name__, msg)
  46. self.__printlog(log_str)
  47. # 外部数据
  48. class XData(CBaseLog):
  49. def __init__(self):
  50. # 配置文件路径;
  51. self.configPath = ""
  52. # menu tree资源目录(包含了Excel文件路径);
  53. self.menuTreeDir = ""
  54. # 默认的excel路径;
  55. self.defaultExcelPath = ""
  56. # tv excel路径;
  57. self.tvExcelPath = ""
  58. # enter key excel路径;
  59. self.enterKeyExcelPath = ""
  60. # menu tree低下的xls或xlsx文件集;
  61. self.listAppExcelPath = []
  62. # 数据状态(只要menuTreeDir和defaultExcelPath有效即为True);
  63. self.status = False
  64. # 加载数据;
  65. self.loadData()
  66. # 装载数据;
  67. def loadData(self):
  68. # 1、加载menu tree 路径;
  69. self.menuTreeDir = getMenuTree3SelectedProjectCfgPath()
  70. if not os.path.isdir(self.menuTreeDir):
  71. self.error(get_fun_name(), "menu tree路径(%s)无效,加载失败!" % tree_path)
  72. return
  73. # endif
  74. self.log("menu tree路径存在:%s" % self.menuTreeDir)
  75. # 2、加载配置文件路径;
  76. self.configPath = os.path.join(self.menuTreeDir, "menutree.ini")
  77. if not os.path.exists(self.configPath):
  78. self.error(get_fun_name(), "配置文件不存在:%s" % self.configPath)
  79. else:
  80. self.log("配置文件存在:%s" % self.configPath)
  81. # 3、加载默认excel文件路径;
  82. self.defaultExcelPath = os.path.join(self.menuTreeDir, "menutree.xls")
  83. if not os.path.exists(self.defaultExcelPath):
  84. self.info(get_fun_name(), "默认menu tree excel文件不存在:%s" % self.defaultExcelPath)
  85. self.defaultExcelPath = os.path.join(self.menuTreeDir, "menutree.xlsx")
  86. # 二次判断是否存在;
  87. if os.path.exists(self.defaultExcelPath):
  88. self.status = True
  89. self.log("默认menu tree excel文件存在:%s" % self.defaultExcelPath)
  90. else:
  91. self.error("默认menu tree excel文件不存在:%s" % self.defaultExcelPath)
  92. # 4、加载tv excel文件;
  93. channel = getMenuTreeSelectedChannel()
  94. if not channel or str(channel) == "":
  95. self.tvExcelPath = self.defaultExcelPath
  96. self.warn(get_fun_name(), "tv表格不存在,使用默认excel=%s" % self.tvExcelPath)
  97. else:
  98. self.tvExcelPath = os.path.join(self.menuTreeDir, "menuTree_" + channel + ".xls")
  99. if not os.path.exists(self.tvExcelPath):
  100. self.tvExcelPath = os.path.join(self.menuTreeDir, "menuTree_" + channel + ".xlsx")
  101. # 二次判断是否存在;
  102. if os.path.exists(self.tvExcelPath):
  103. self.log("默认menu tree excel文件存在:%s" % self.tvExcelPath)
  104. else:
  105. self.error("默认menu tree excel文件不存在:%s" % self.tvExcelPath)
  106. # 5、加载默认excel文件路径;
  107. self.enterKeyExcelPath = os.path.join(self.menuTreeDir, "eventkey_code.xls")
  108. if not os.path.exists(self.enterKeyExcelPath):
  109. self.info(get_fun_name(), "eventkey_code文件不存在:%s" % self.enterKeyExcelPath)
  110. self.enterKeyExcelPath = os.path.join(self.menuTreeDir, "eventkey_code.xlsx")
  111. # 二次判断是否存在;
  112. if os.path.exists(self.enterKeyExcelPath):
  113. self.log("eventkey_code文件存在:%s" % self.enterKeyExcelPath)
  114. else:
  115. self.error(get_fun_name(), "eventkey_code文件不存在:%s" % self.enterKeyExcelPath)
  116. # 6、加载UITree开头的所有xls或xlsx
  117. fileList = os.listdir(self.menuTreeDir)
  118. self.listAppExcelPath.append(self.defaultExcelPath)
  119. if self.defaultExcelPath != self.tvExcelPath:
  120. self.listAppExcelPath.append(self.tvExcelPath)
  121. for filePath in fileList:
  122. if filePath.lower().startswith("uitree") and (
  123. filePath.lower().endswith(".xls") or filePath.lower().endswith(".xlsx")):
  124. self.listAppExcelPath.append(os.path.join(self.menuTreeDir, filePath))
  125. # Option数据逻辑类;
  126. class COptionDataLogic(CBaseLog):
  127. def __init__(self, xdata):
  128. # 路径位置索引;
  129. self.__pos = 0
  130. if xdata is None:
  131. self.error(get_fun_name(), "xdata对象空")
  132. # 获取当前option名称;
  133. def getOptionName(self):
  134. pass
  135. # 获取当前option的xls中的others字段;
  136. def getOptionOthers(self, optionName):
  137. pass
  138. def getOptionConfig(self, optionName):
  139. pass
  140. def getOptionMoveKey(self, optionName):
  141. pass
  142. def getOptionBackKey(self, optionName):
  143. pass
  144. def getOptionEnterKey(self, optionName):
  145. pass
  146. # 获取option的ocr文本;
  147. def getOptionText(self, optionName):
  148. pass
  149. # 获取当前option的子项(子option名称集合)
  150. def getOptionSubItems(self, optionName):
  151. pass
  152. def getOptionParentName(self, optionName):
  153. pass
  154. def getOptionShortCutKey(self, optionName):
  155. pass
  156. # Option定位逻辑类;
  157. class COptionFocusLogic(CBaseLog):
  158. def __init__(self):
  159. pass
  160. # Option的文字识别逻辑类;
  161. class COptionOCRLogic(CBaseLog):
  162. def __init__(self):
  163. pass
  164. # Option的动作逻辑类
  165. class COptionActionLogic(CBaseLog):
  166. # 目标节点名称, 目标节点设置值
  167. def __init__(self, tagOptionName, tagOptionSetValue):
  168. # 私有变量:节点位置,默认根结点(0)
  169. self.__pos = 0
  170. # 节点路径;
  171. self.__paths = None
  172. # 加载节点数据;
  173. self.__LoadOptionData()
  174. def __LoadOptionData(self):
  175. pass
  176. # 是否在第一节点(根结点)
  177. def IsOnFirstOption(self):
  178. pass
  179. # 调用根节点快捷键(中间节点不需要快捷键;);
  180. def CallFirstOptionShortCutKey(self):
  181. pass
  182. # 调用当前结点的toparent_key;
  183. def CallCurOptionBackKey(self):
  184. pass
  185. # 是否聚集到当前(self.__pos)节点;
  186. def IsOnCurOption(self):
  187. pass
  188. # 从当前节点开始向后移动;
  189. def Move2NextOption(self):
  190. pass
  191. # 从当前节点开始向前返回;
  192. def Move2PrevOption(self):
  193. pass
  194. # 获取当前Option名称;
  195. def GetCurOptionName(self):
  196. pass
  197. # 获取当前Option配置;
  198. def GetCurOptoinConfig(self):
  199. pass
  200. # 获取当前Option表信息;
  201. def GetCurOptionExcelInfo(self):
  202. pass
  203. if __name__ == "__main__":
  204. xdata = XData()
  205. optdatalogic = COptionDataLogic(None)