PySysDB/Éú³ÉIpyGameDataPY/IpyGameDataPYCreater.py
@@ -8,8 +8,12 @@
cfg = ConfigParser.ConfigParser()
cfg.read("config.ini")
CodeProjectPath = cfg.get("config", "CodeProjectPath") # ä»£ç é¡¹ç›®è·¯å¾„
CodeProjectPath = "" # ä»£ç é¡¹ç›®è·¯å¾„
for i in range(1, 20):
    folderPath = cfg.get("config", "CodeProjectPath%s" % i)
    if os.path.isdir(folderPath):
        CodeProjectPath = folderPath
        break
IpyGameDataFile = "IpyGameDataPY.py" # ç”Ÿæˆçš„py文件名
# è¡¨ç»“构定义字典模板
@@ -31,15 +35,19 @@
# ç±»åˆå§‹åŒ–数值对象模板
ClassInitTemp = "        self.%s = %s%s"
# èŽ·å–ç±»å¯¹è±¡å‡½æ•°æ¨¡æ¿
ClassFuncTemp = "    def Get%s(self): return self.%s%s%s"
ClassFuncTemp = "    def Get%s(self): return self.%s%s %s%s"
# ç®¡ç†å™¨åˆå§‹åŒ–表数据缓存列表对象模板
MgrTableCacheInit = "        self.ipy%sCache = self.__LoadFileData(\"%s\", IPY_%s)%s"
MgrTableLenInit = "        self.ipy%sLen = len(self.ipy%sCache)%s"
# ç®¡ç†å™¨èŽ·å–è¡¨æ•°æ®æ¡æ•°å‡½æ•°æ¨¡æ¿
MgrGetCountFunc = "    def Get%sCount(self): return self.ipy%sLen%s"
# ç®¡ç†å™¨æ ¹æ®ç´¢å¼•获取表数据函数模板
MgrGetByIndexFunc = "    def Get%sByIndex(self, index): return self.ipy%sCache[index]%s"
MgrTableCacheInit = "        self.__LoadFileData(\"%s\", onlyCheck)%s"
# ç®¡ç†å™¨èŽ·å–è¡¨æ•°æ®æ¡æ•°ã€æ•°æ®å‡½æ•°æ¨¡æ¿
MgrGetCountFunc = '''
    def Get%sCount(self):
        self.CheckLoadData("%s")
        return self.ipy%sLen\r
    def Get%sByIndex(self, index):
        self.CheckLoadData("%s")
        return self.ipy%sCache[index]\r
'''
Def_RN = "\r\n"
@@ -94,7 +102,7 @@
                tableName = tableName.replace(" ", "") # è¡¨åè‹±æ–‡å
                continue
            
            noteInfo = "" # å­—段注释说明
            noteInfo = " #" # å­—段注释说明
            if "//" in line:
                signIndex = line.index("//")
                noteInfo = " # %s" % line[signIndex+2:].rstrip()
@@ -155,19 +163,18 @@
                classInitInfo += ClassInitTemp % (fieldName, "0.0", lineEnd)
            else:
                classInitInfo += ClassInitTemp % (fieldName, "0", lineEnd)
            classFuncInfo += ClassFuncTemp % (fieldName, fieldName, noteInfo, lineEnd)
            callAttrValue = "attrTuple[%s]" % j # fieldName
            classFuncInfo += ClassFuncTemp % (fieldName, callAttrValue, noteInfo, fieldType, lineEnd)
            
        ipyTableDef += TableDefEnd % (Def_RN if i == len(Def_IpyTable) - 1 else (Def_RN * 2))
        classInitInfo = ClassInitTemp % ("attrTuple", "None", "") # ä¼˜åŒ–内存,不使用内置 __dict__ è®¿é—®å±žæ€§ï¼Œæ”¹ä¸ºä½¿ç”¨tuple存value
        classContent += ClassTemp % (tableNameCh, tableName, classInitInfo, classFuncInfo)
        
        # è¡¨åˆ—表、长度对象缓存
        mgrTableCacheObjInit += MgrTableCacheInit % (tableName, tableName, tableName, Def_RN)
        mgrTableCacheObjInit += MgrTableLenInit % (tableName, tableName, Def_RN)
        mgrTableCacheObjInit += MgrTableCacheInit % (tableName, Def_RN)
        
        # è¡¨åˆ—表、长度获取函数
        mgrTableFunc += MgrGetCountFunc % (tableName, tableName, Def_RN)
        mgrTableFunc += MgrGetByIndexFunc % (tableName, tableName, Def_RN)
        mgrTableFunc += MgrGetCountFunc % (tableName, tableName, tableName, tableName, tableName, tableName)
    
    # è¯»å–模板生成py代码
    createPYContent = ""