Option.py 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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()[2][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, msg):
  28. # 类型/类名:函数/内容
  29. log_str = "【DEBUG】<%s::%s> %s" % (self.__class__.__name__, get_fun_name(), msg)
  30. self.__printlog(log_str)
  31. def info(self, msg):
  32. # 类型/类名:函数/内容
  33. log_str = "【INFO】<%s::%s> %s" % (self.__class__.__name__, get_fun_name(), msg)
  34. self.__printlog(log_str)
  35. def warn(self, msg):
  36. # 类型/类名:函数/内容
  37. log_str = "【WARN】<%s::%s> %s" % (self.__class__.__name__, get_fun_name(), msg)
  38. self.__printlog(log_str)
  39. def error(self, msg):
  40. # 类型/类名:函数/内容
  41. log_str = "【ERROR】<%s::%s> %s" % (self.__class__.__name__, get_fun_name(), msg)
  42. self.__printlog(log_str)
  43. def log(self, msg):
  44. # 类型/类名/内容
  45. log_str = "【LOG】<%s::%s> %s" % (self.__class__.__name__, get_fun_name(), msg)
  46. self.__printlog(log_str)
  47. # 外部数据
  48. class CXData(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("menu tree路径(%s)无效,加载失败!" % self.menuTreeDir)
  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("配置文件不存在:%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("默认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("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("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( "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. @property
  126. def configPath(self):
  127. return self.__configPath
  128. @property
  129. def menuTreeDir(self):
  130. return self.__menuTreeDir
  131. @property
  132. def defaultExcelPath(self):
  133. return self.__defaultExcelPath
  134. @property
  135. def tvExcelPath(self):
  136. return self.__tvExcelPath
  137. @property
  138. def enterKeyExcelPath(self):
  139. return self.__enterKeyExcelPath
  140. @property
  141. def listAppExcelPath(self):
  142. return self.__listAppExcelPath
  143. @property
  144. def status(self):
  145. return self.__status
  146. # 内部数据;
  147. class CMetaData(CBaseLog):
  148. def __init__(self, xdata):
  149. pass
  150. def loadConfig(self):
  151. xdata.ConfigPath
  152. def LoadExcel(self):
  153. pass
  154. def getOptionConfig(self, pos):
  155. pass
  156. def getOptionValue(self, pos):
  157. pass
  158. def getOptionName(self, pos):
  159. pass
  160. def getOptionOthers(self, pos):
  161. pass
  162. def getOptionEnterKey(self, pos):
  163. pass
  164. def getOptionMoveKey(self, pos):
  165. pass
  166. def getOptionShortCutKey(self, pos):
  167. pass
  168. def getOptionBackKey(self, pos):
  169. pass
  170. def getOptionLayout(self, pos):
  171. pass
  172. # Option数据逻辑类;
  173. class COptionDataLogic(CBaseLog):
  174. def __init__(self, xdata):
  175. # 路径位置索引;
  176. self.__pos = 0
  177. if xdata is None:
  178. self.error(get_fun_name(), "xdata对象空")
  179. # 获取当前option名称;
  180. def getOptionName(self):
  181. pass
  182. # 获取当前option的xls中的others字段;
  183. def getOptionOthers(self, optionName):
  184. pass
  185. def getOptionConfig(self, optionName):
  186. pass
  187. def getOptionMoveKey(self, optionName):
  188. pass
  189. def getOptionBackKey(self, optionName):
  190. pass
  191. def getOptionEnterKey(self, optionName):
  192. pass
  193. # 获取option的ocr文本;
  194. def getOptionText(self, optionName):
  195. pass
  196. # 获取当前option的子项(子option名称集合)
  197. def getOptionSubItems(self, optionName):
  198. pass
  199. def getOptionParentName(self, optionName):
  200. pass
  201. def getOptionShortCutKey(self, optionName):
  202. pass
  203. # Option定位逻辑类;
  204. class COptionFocusLogic(CBaseLog):
  205. def __init__(self):
  206. pass
  207. # Option的文字识别逻辑类;
  208. class COptionOCRLogic(CBaseLog):
  209. def __init__(self):
  210. pass
  211. # Option的动作逻辑类
  212. class COptionActionLogic(CBaseLog):
  213. # 目标节点名称, 目标节点设置值
  214. def __init__(self, tagOptionName, tagOptionSetValue):
  215. # 私有变量:节点位置,默认根结点(0)
  216. self.__pos = 0
  217. # 节点路径;
  218. self.__paths = None
  219. # 加载节点数据;
  220. self.__LoadOptionData()
  221. def __LoadOptionData(self):
  222. pass
  223. # 是否在第一节点(根结点)
  224. def IsOnFirstOption(self):
  225. pass
  226. # 调用根节点快捷键(中间节点不需要快捷键;);
  227. def CallFirstOptionShortCutKey(self):
  228. pass
  229. # 调用当前结点的toparent_key;
  230. def CallCurOptionBackKey(self):
  231. pass
  232. # 是否聚集到当前(self.__pos)节点;
  233. def IsOnCurOption(self):
  234. pass
  235. # 从当前节点开始向后移动;
  236. def Move2NextOption(self):
  237. pass
  238. # 从当前节点开始向前返回;
  239. def Move2PrevOption(self):
  240. pass
  241. # 获取当前Option名称;
  242. def GetCurOptionName(self):
  243. pass
  244. # 获取当前Option配置;
  245. def GetCurOptoinConfig(self):
  246. pass
  247. # 获取当前Option表信息;
  248. def GetCurOptionExcelInfo(self):
  249. pass
  250. class CTest(CBaseLog):
  251. def __init__(self):
  252. pass
  253. def Log(self):
  254. self.info("fff", "cccc")
  255. if __name__ == "__main__":
  256. xdata = CXData()
  257. #optdatalogic = COptionDataLogic(None)