123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- # -*- coding:utf-8 -*-
- """
- 注:私有变量和函数,前面加双下划线(不要在后面也加双下划线);
- """
- import os
- import sys
- import time
- # 使用inspect模块动态获取当前运行的函数名
- import inspect
- # 日期头文件;
- from datetime import datetime
- # 自动化sdk头;
- from ssat_sdk.sat_environment import getMenuTree3SelectedPExcelPath
- from ssat_sdk.sat_environment import getMenuTree3SelectedProjectCfgPath
- from ssat_sdk.sat_environment import getMenuTree3SelectedTvExcelPath
- from ssat_sdk.sat_environment import getMenuTreeSelectedChannel
- # 获取运行函数名;
- def get_fun_name():
- return inspect.stack()[1][3]
- # 日志基类;
- class CBaseLog:
- def __init__(self):
- pass
- def __printlog(self, msg):
- # 时间/内容;
- print("%s %s") % (datetime.now().strftime('%Y-%m-%d %H:%M:%S'), msg)
- def debug(self, fun, msg):
- # 类型/类名:函数/内容
- log_str = "【DEBUG】<%s::%s> %s" % (self.__class__.__name__, fun, msg)
- self.__printlog(log_str)
- def info(self, fun, msg):
- # 类型/类名:函数/内容
- log_str = "【INFO】<%s::%s> %s" % (self.__class__.__name__, fun, msg)
- self.__printlog(log_str)
- def warn(self, fun, msg):
- # 类型/类名:函数/内容
- log_str = "【WARN】<%s::%s> %s" % (self.__class__.__name__, fun, msg)
- self.__printlog(log_str)
- def error(self, fun, msg):
- # 类型/类名:函数/内容
- log_str = "【ERROR】<%s::%s> %s" % (self.__class__.__name__, fun, msg)
- self.__printlog(log_str)
- def log(self, msg):
- # 类型/类名/内容
- log_str = "【LOG】<%s> %s" % (self.__class__.__name__, msg)
- self.__printlog(log_str)
- # 外部数据
- class XData(CBaseLog):
- def __init__(self):
- # 配置文件路径;
- self.configPath = ""
- # menu tree资源目录(包含了Excel文件路径);
- self.menuTreeDir = ""
- # 默认的excel路径;
- self.defaultExcelPath = ""
- # tv excel路径;
- self.tvExcelPath = ""
- # enter key excel路径;
- self.enterKeyExcelPath = ""
- # menu tree低下的xls或xlsx文件集;
- self.listAppExcelPath = []
- # 数据状态(只要menuTreeDir和defaultExcelPath有效即为True);
- self.status = False
- # 加载数据;
- self.loadData()
- # 装载数据;
- def loadData(self):
- # 1、加载menu tree 路径;
- self.menuTreeDir = getMenuTree3SelectedProjectCfgPath()
- if not os.path.isdir(self.menuTreeDir):
- self.error(get_fun_name(), "menu tree路径(%s)无效,加载失败!" % tree_path)
- return
- # endif
- self.log("menu tree路径存在:%s" % self.menuTreeDir)
- # 2、加载配置文件路径;
- self.configPath = os.path.join(self.menuTreeDir, "menutree.ini")
- if not os.path.exists(self.configPath):
- self.error(get_fun_name(), "配置文件不存在:%s" % self.configPath)
- else:
- self.log("配置文件存在:%s" % self.configPath)
- # 3、加载默认excel文件路径;
- self.defaultExcelPath = os.path.join(self.menuTreeDir, "menutree.xls")
- if not os.path.exists(self.defaultExcelPath):
- self.info(get_fun_name(), "默认menu tree excel文件不存在:%s" % self.defaultExcelPath)
- self.defaultExcelPath = os.path.join(self.menuTreeDir, "menutree.xlsx")
- # 二次判断是否存在;
- if os.path.exists(self.defaultExcelPath):
- self.status = True
- self.log("默认menu tree excel文件存在:%s" % self.defaultExcelPath)
- else:
- self.error("默认menu tree excel文件不存在:%s" % self.defaultExcelPath)
- # 4、加载tv excel文件;
- channel = getMenuTreeSelectedChannel()
- if not channel or str(channel) == "":
- self.tvExcelPath = self.defaultExcelPath
- self.warn(get_fun_name(), "tv表格不存在,使用默认excel=%s" % self.tvExcelPath)
- else:
- self.tvExcelPath = os.path.join(self.menuTreeDir, "menuTree_" + channel + ".xls")
- if not os.path.exists(self.tvExcelPath):
- self.tvExcelPath = os.path.join(self.menuTreeDir, "menuTree_" + channel + ".xlsx")
- # 二次判断是否存在;
- if os.path.exists(self.tvExcelPath):
- self.log("默认menu tree excel文件存在:%s" % self.tvExcelPath)
- else:
- self.error("默认menu tree excel文件不存在:%s" % self.tvExcelPath)
- # 5、加载默认excel文件路径;
- self.enterKeyExcelPath = os.path.join(self.menuTreeDir, "eventkey_code.xls")
- if not os.path.exists(self.enterKeyExcelPath):
- self.info(get_fun_name(), "eventkey_code文件不存在:%s" % self.enterKeyExcelPath)
- self.enterKeyExcelPath = os.path.join(self.menuTreeDir, "eventkey_code.xlsx")
- # 二次判断是否存在;
- if os.path.exists(self.enterKeyExcelPath):
- self.log("eventkey_code文件存在:%s" % self.enterKeyExcelPath)
- else:
- self.error(get_fun_name(), "eventkey_code文件不存在:%s" % self.enterKeyExcelPath)
- # 6、加载UITree开头的所有xls或xlsx
- fileList = os.listdir(self.menuTreeDir)
- self.listAppExcelPath.append(self.defaultExcelPath)
- if self.defaultExcelPath != self.tvExcelPath:
- self.listAppExcelPath.append(self.tvExcelPath)
- for filePath in fileList:
- if filePath.lower().startswith("uitree") and (
- filePath.lower().endswith(".xls") or filePath.lower().endswith(".xlsx")):
- self.listAppExcelPath.append(os.path.join(self.menuTreeDir, filePath))
- # Option数据逻辑类;
- class COptionDataLogic(CBaseLog):
- def __init__(self, xdata):
- # 路径位置索引;
- self.__pos = 0
- if xdata is None:
- self.error(get_fun_name(), "xdata对象空")
- # 获取当前option名称;
- def getOptionName(self):
- pass
- # 获取当前option的xls中的others字段;
- def getOptionOthers(self, optionName):
- pass
- def getOptionConfig(self, optionName):
- pass
- def getOptionMoveKey(self, optionName):
- pass
- def getOptionBackKey(self, optionName):
- pass
- def getOptionEnterKey(self, optionName):
- pass
- # 获取option的ocr文本;
- def getOptionText(self, optionName):
- pass
- # 获取当前option的子项(子option名称集合)
- def getOptionSubItems(self, optionName):
- pass
- def getOptionParentName(self, optionName):
- pass
- def getOptionShortCutKey(self, optionName):
- pass
- # Option定位逻辑类;
- class COptionFocusLogic(CBaseLog):
- def __init__(self):
- pass
- # Option的文字识别逻辑类;
- class COptionOCRLogic(CBaseLog):
- def __init__(self):
- pass
- # Option的动作逻辑类
- class COptionActionLogic(CBaseLog):
- # 目标节点名称, 目标节点设置值
- def __init__(self, tagOptionName, tagOptionSetValue):
- # 私有变量:节点位置,默认根结点(0)
- self.__pos = 0
- # 节点路径;
- self.__paths = None
- # 加载节点数据;
- self.__LoadOptionData()
- def __LoadOptionData(self):
- pass
- # 是否在第一节点(根结点)
- def IsOnFirstOption(self):
- pass
- # 调用根节点快捷键(中间节点不需要快捷键;);
- def CallFirstOptionShortCutKey(self):
- pass
- # 调用当前结点的toparent_key;
- def CallCurOptionBackKey(self):
- pass
- # 是否聚集到当前(self.__pos)节点;
- def IsOnCurOption(self):
- pass
- # 从当前节点开始向后移动;
- def Move2NextOption(self):
- pass
- # 从当前节点开始向前返回;
- def Move2PrevOption(self):
- pass
- # 获取当前Option名称;
- def GetCurOptionName(self):
- pass
- # 获取当前Option配置;
- def GetCurOptoinConfig(self):
- pass
- # 获取当前Option表信息;
- def GetCurOptionExcelInfo(self):
- pass
- if __name__ == "__main__":
- xdata = XData()
- optdatalogic = COptionDataLogic(None)
|