Beispiel #1
0
 def deleteMata(self, folderName_: str):
     _jsCodeFolder = fileUtils.getPath(self._assetsFolderPath, folderName_)
     _filePathDict = folderUtils.getFilePathKeyValue(
         _jsCodeFolder, [".meta"])
     # 移除掉无用的meta文件
     for _keyName, _filePath in _filePathDict.items():
         fileUtils.removeExistFile(_filePath)
Beispiel #2
0
    def analysePrefabComponentRelationShip(self):
        _prefabPathDict = folderUtils.getFilePathKeyValue(self._prefabFolder, [".prefab"])
        for _, _prefabPath in _prefabPathDict.items():
            _prefabFileName = fileUtils.justName(_prefabPath)
            # prefab 文件 对应 Component 的 列表
            self.prefabComponentDict[_prefabFileName] = []
            # prefab 的 列表
            _prefabList = fileUtils.dictFromJsonFile(_prefabPath)
            # prefab 内容
            for _i in range(len(_prefabList)):
                # prefab 的 每一个 元素
                _elementDict = _prefabList[_i]
                # 每一个 元素 的 类型
                _elementType = _elementDict['__type__']
                # 组件 和 加密字符串 的 对应字典。
                if _elementType in self.componentEncryptClassDict.keys():
                    _componentJSName = self.componentEncryptClassDict[_elementType]  # 转换成 js 脚本名
                    self.prefabComponentDict[_prefabFileName].append(_componentJSName)  # 获取 Prefab 上的 js Component 脚本

        _keyList = []
        for _key, _list in self.prefabComponentDict.items():
            if len(_list) == 0:
                _keyList.append(_key)

        for _key in _keyList:
            del self.prefabComponentDict[_key]

        for _key, _list in self.prefabComponentDict.items():
            if _key != _list[0]:
                self.raiseError(pyUtils.getCurrentRunningFunctionName(),
                                " 界面名 和 component 名称 不一致 " + _key + " : " + _list[0])
Beispiel #3
0
 def displayJsonStructure(self):
     _targetJsonPath = fileUtils.getPath(
         "/Volumes/18604037792/develop/ShunYuan/wxGame/assets/resources/Json/",
         "")
     _filePathDict = folderUtils.getFilePathKeyValue(
         _targetJsonPath, [".json"])
     for _keyName, _filePath in _filePathDict.items():
         print(_filePath)
Beispiel #4
0
    def analysePrefabFolderStructure(self):
        _prefabPathDict = folderUtils.getFilePathKeyValue(self._prefabFolder, [".prefab"])

        _pathList = []
        for _, _prefabPath in _prefabPathDict.items():
            self.analysePrefabStructure(_prefabPath, _pathList)

        # 所有的字段类型
        _pathList.sort()
        return _pathList
Beispiel #5
0
    def createPbFile(self, protoFolderPath_: str, pbCreateFolderPath_: str):
        _filePathDict = folderUtils.getFilePathKeyValue(protoFolderPath_, [".proto"])
        for _protoName, _protoPath in _filePathDict.items():
            _protoShortPath = _protoPath.split(protoFolderPath_)[1]
            _pbShortPath = _protoShortPath.split(".proto")[0] + ".pb"
            _cmd = "protoc --descriptor_set_out ./{0} ./{1}".format(_pbShortPath, _protoShortPath)
            print('_cmd = ' + str(_cmd))
            subprocess.Popen(_cmd, shell=True, cwd=protoFolderPath_)

        fileCopyUtils.copyFilesInFolderTo([".pb"], protoFolderPath_, pbCreateFolderPath_, "include", True)
        folderUtils.removeFileByFilter(protoFolderPath_, [".pb"])
Beispiel #6
0
 def getProviderCodeByFolder(self, folder_: str, fileTypes_: list,
                             codeTemplet_: str):
     _code = ""
     # 获取文件名和文件路径的字典
     _fileDict = folderUtils.getFilePathKeyValue(folder_, fileTypes_)
     for _key in _fileDict:
         _keyName = _key.split(".")[0]
         _pathWithOutSuffix = fileUtils.pathWithOutSuffix(_key, folder_)
         _relativePathWithOutSuffix = _pathWithOutSuffix.split(folder_)[1]
         _code = _code + codeTemplet_.format(
             key=_keyName, path=_relativePathWithOutSuffix) + "\n"
     return _code
Beispiel #7
0
 def getMetaByUUID(self, UUID: str):
     _targetAssetsFolder = fileUtils.getPath(self._assetsFolderPath, "")
     _filePathDict = folderUtils.getFilePathKeyValue(
         _targetAssetsFolder, [".meta"])
     _find = False
     for _, _filePath in _filePathDict.items():
         _fileMetaDict = fileUtils.dictFromJsonFile(_filePath)
         if _fileMetaDict["uuid"] == UUID:
             print(_filePath)
             _find = True
     if not _find:
         print("uuid {0} none.".format(UUID))
Beispiel #8
0
 def Replace(self, dParameters_: dict):
     _sourceFolderPath = sysUtils.folderPathFixEnd(dParameters_["sourceFolder"])
     _targetFolderPath = sysUtils.folderPathFixEnd(dParameters_["targetFolder"])
     _filters = dParameters_["filters"]  # 过滤项
     _filePathDict = folderUtils.getFilePathKeyValue(_sourceFolderPath, _filters)
     for _, _filePath in _filePathDict.items():  # 存在文件,才拷贝
         _shortPath = _filePath.split(_sourceFolderPath)[1]
         _tarfilePath = _targetFolderPath + _shortPath
         _sourcefilePath = _sourceFolderPath + _shortPath
         if os.path.exists(_tarfilePath):
             print('        copy to : ' + str(_tarfilePath))
             shutil.copy(_sourcefilePath, _tarfilePath)
         else:
             print('x-      pass : ' + str(_sourcefilePath))
Beispiel #9
0
 def analyseFolder(self, folderName_: str):
     _swiftCodeFolder = fileUtils.getPath(self.resPath, folderName_)
     _filePathDict = folderUtils.getFilePathKeyValue(
         _swiftCodeFolder, [".swift"])
     for _k, _v in _filePathDict.items():
         _keyName = _k
         print(str(_keyName).ljust(40) + ":" + str(_v))  # 名称 -> 路径 关系输出
         if _keyName == "2 - MyGameCoordinator.swift":
             _codeWithComment = fileUtils.readFromFile(_v)
             _codeWithOutComment = codeUtils.removeComment(
                 "swift", _codeWithComment)
             for _idx, _line in list(
                     enumerate(_codeWithOutComment.split("\n"))):
                 print(str(_idx).ljust(3) + ":" + str(_line))
Beispiel #10
0
 def getProtobufStructInfoDict(self, protoFolderPath_):
     _protoStructInfoDict = {}
     _filePathDict = folderUtils.getFilePathKeyValue(protoFolderPath_, [".proto"])
     for _k, _v in _filePathDict.items():
         _keyName = _k.split("/")[-1].split(".")[0]
         # 名称 -> 路径 关系输出
         # print(str(_keyName).ljust(15) + ":" + str(_v))
         _currentProtoInfo = self.getProtobufStructInfo(_keyName, _v)
         _protoStructInfoDict[_keyName] = _currentProtoInfo
         # 输出 proto 结构信息
         # print(str(json.dumps(_currentProtoInfo, indent=4, sort_keys=False, ensure_ascii=False)))
         # 输出 proto 结构的 json 结构样式
         # dictUtils.showDictStructure(_currentProtoInfo)
     return _protoStructInfoDict
Beispiel #11
0
    def analyseJsCode(self, folderName_: str):
        _jsCodeFolder = fileUtils.getPath(self._assetsFolderPath, folderName_)
        _filePathDict = folderUtils.getFilePathKeyValue(_jsCodeFolder, [".js"])
        # 代码中使用function的次数
        _funcLineCount = 0

        # 正则表达式队列
        for _, _filePath in _filePathDict.items():
            # 做判断的,用来显示的路径
            fileShowName = _filePath.split(folderName_)[1]
            if fileShowName in self._unAnalyseFileList:
                continue
            _funcLineCount += self.analyseSingle(_filePath, folderName_)

        print('共有 {0} 处function使用'.format(_funcLineCount))
Beispiel #12
0
 def coverFiles(self, typeFilters_: list, sourceFolderPath_: str,
                targetFolderPath_: str):
     print("CopyFiles -> coverFiles : \n    " + sourceFolderPath_ + " -> " +
           targetFolderPath_)
     _filePathDict = folderUtils.getFilePathKeyValue(
         targetFolderPath_, typeFilters_)
     for _fileName, _filePath in _filePathDict.items():
         _shortPath = _filePath.split(targetFolderPath_)[1]
         _tarfilePath = targetFolderPath_ + _shortPath
         _sourcefilePath = sourceFolderPath_ + _shortPath
         # 存在这文件,就拷贝
         if os.path.exists(_sourcefilePath):
             print('        copy : ' + str(_fileName))
             shutil.copy(_sourcefilePath, _tarfilePath)
         else:
             print('x-      pass : ' + str(_fileName) + " not exist.")
Beispiel #13
0
    def PbCreator(self, dParameters_: dict):
        _protoFolderPath = sysUtils.folderPathFixEnd(dParameters_["protoFolderPath"])
        _pbFolderPath = sysUtils.folderPathFixEnd(dParameters_["pbFolderPath"])
        _filePathDict = folderUtils.getFilePathKeyValue(_protoFolderPath, [".proto"])
        for _, _protoPath in _filePathDict.items():  # 每一个proto文件
            _protoShortPath = _protoPath.split(_protoFolderPath)[1]
            _pbShortPath = _protoShortPath.split(".proto")[0] + ".pb"
            _cmd = "protoc --descriptor_set_out ./{0} ./{1}".format(_pbShortPath, _protoShortPath)
            cmdUtils.doStrAsCmd(
                _cmd,
                _protoFolderPath,
                True
            )

        # 将生成出来的.pb文件拷贝到目标文件一份
        fileCopyUtils.copyFilesInFolderTo([".pb"], _protoFolderPath, _pbFolderPath, "include", True)
        folderUtils.removeFileByFilter(_protoFolderPath, [".pb"])  # 再删除刚拷贝过的.pb文件
Beispiel #14
0
    def getTableInfoDictFormFolder(self, protoFolderPath_: str):
        _protoStructInfoDict = {}
        _filePathDict = folderUtils.getFilePathKeyValue(
            protoFolderPath_, [".proto"])
        for _protoFileName, _protoFilePath in _filePathDict.items():
            _keyName = _protoFileName.split("/")[-1].split(".")[0]
            _currentProtoInfo = self.protoStructInfo.getProtobufStructInfo(
                _protoFileName, _protoFilePath)
            _protoStructInfoDict[_keyName] = _currentProtoInfo

        # 表字典
        _tableDict = {}
        for _protoName, _protoSturct in _protoStructInfoDict.items():
            _tableList = _protoSturct["tableList"]
            for _table in _tableList:
                _protoName = _table["protoName"]
                if _protoName in _tableDict:
                    self.raiseError(pyUtils.getCurrentRunningFunctionName(),
                                    "已经存在 : " + _protoName)
                _tableDict[_protoName] = _table
        return _tableDict
 def anaylseShortJsNameAndRequireRelation(self):
     _filePathDict = folderUtils.getFilePathKeyValue(
         self._jsFolder, [".js"])
     for _, _filePath in _filePathDict.items():
         _jsFileShortName = _filePath.split(self._jsFolder)[1]
         self._requireDict[_jsFileShortName] = []
         if not (_jsFileShortName in self._jsAllShortNameList):
             self._jsAllShortNameList.append(_jsFileShortName)
         # 内容中识别 require
         _content = fileUtils.readFromFile(_filePath)
         regex = r"var\s*([0-9a-z-A-Z_\.]+)\s*=\s*require\(\s*\"([0-9a-z-A-Z_\.]+)\"\s*\)"
         matches = re.finditer(regex, _content, re.MULTILINE)
         for matchNum, match in enumerate(matches, start=1):
             _localName = match.group(1)  # 代码中的名称
             _fileName = match.group(2)  # 引用名称
             _lines = _content.split("\n")
             _isFind = False
             for _line in _lines:
                 # 注释的前半截
                 _line = _line.split("//")[0]
                 # 在不是require的行中搜索
                 if not re.search(
                         r'require\(\s*\"([0-9a-z-A-Z_\.]+)\"\s*\)',
                         _line) and _line.find("module.exports") < 0:
                     if (re.search(
                             r'[\s\(\[=\!\+\-\*/\']' + _localName +
                             '[\,\.\s=\)\]\+\-\*/\'\[]', _line)):
                         _isFind = True
                         break
             if _isFind:
                 self._requireDict[_jsFileShortName].append(_fileName)
             else:
                 print(_filePath)
                 print(_fileName)
                 self.raiseError(pyUtils.getCurrentRunningFunctionName(),
                                 "文件引用了类,但是没有使用过")
Beispiel #16
0
 def analysePrefabFolder(self):
     _filePathDict = folderUtils.getFilePathKeyValue(self._prefabFolder, [".prefab"])
     for _, _filePath in _filePathDict.items():
         self.analysePrefab(_filePath)
Beispiel #17
0
 def __init__(self, sm_):
     super().__init__(sm_)
     self.excelPathDict = folderUtils.getFilePathKeyValue(
         excelFolderPath, [".xlsx"])
 def analysePrefab(self):
     _filePathDict = folderUtils.getFilePathKeyValue(
         self._jsFolder, [".js"])
     for _, _filePath in _filePathDict.items():
         self.analysePrefabJS(_filePath)
Beispiel #19
0
    def analyse(self):
        _filePathDict = folderUtils.getFilePathKeyValue(self._jsFolder, [".js"])
        for _fileName, _filePath in _filePathDict.items():
            if _fileName in self._jsNameFilterList:
                continue
            self.analyseJS(_filePath)

        # 冲解析出来的协议行中获取信息
        for _line in self._sendLines:
            _sendResult = re.search(r'.*\(protocal\.([0-9a-z-A-Z_]+)', _line)
            _protoName = _sendResult.group(1)
            if not (_protoName in self._sendProtoNameList):
                self._sendProtoNameList.append(_protoName)
            if not (_protoName in self._allProtoNameList):
                self._allProtoNameList.append(_protoName)

        for _line in self._onLines:
            _sendResult = re.search(r'.*\(protocal\.([0-9a-z-A-Z_]+)', _line)
            _protoName = _sendResult.group(1)
            if not (_protoName in self._onProtoNameList):
                self._onProtoNameList.append(_protoName)
            if not (_protoName in self._allProtoNameList):
                self._allProtoNameList.append(_protoName)

        for _line in self._offLines:
            _sendResult = re.search(r'.*\(protocal\.([0-9a-z-A-Z_]+)', _line)
            _protoName = _sendResult.group(1)
            if not (_protoName in self._offProtoNameList):
                self._offProtoNameList.append(_protoName)
            if not (_protoName in self._allProtoNameList):
                self._allProtoNameList.append(_protoName)

        matches = re.finditer(r'protocal\.([0-9a-z-A-Z_]+)', "\n".join(self._otherLines), re.MULTILINE)
        for matchNum, match in enumerate(matches, start=1):
            for groupNum in range(0, len(match.groups())):
                groupNum = groupNum + 1
                _protoName = match.group(groupNum)
                if not (_protoName in self._otherProtoNameList) and \
                        not (_protoName in self._sendProtoNameList) and \
                        not (_protoName in self._onProtoNameList) and \
                        not (_protoName in self._offProtoNameList):
                    self._otherProtoNameList.append(_protoName)
                if not (_protoName in self._allProtoNameList):
                    self._allProtoNameList.append(_protoName)

        print("other --------")
        for _protoName in self._otherProtoNameList:
            print("    " + _protoName)

        print("send --------")
        for _protoName in self._sendProtoNameList:
            print("    " + _protoName)

        # print("on --------")
        # for _protoName in self._onProtoNameList:
        #     print("    " + _protoName)
        #
        # print("off --------")
        # for _protoName in self._offProtoNameList:
        #     print("    " + _protoName)

        print("on but not off --------")
        for _protoName in self._onProtoNameList:
            if not _protoName in self._offProtoNameList:
                print("    " + _protoName)

        print("on and off --------")
        for _protoName in self._onProtoNameList:
            if _protoName in self._offProtoNameList:
                print("    " + _protoName)

        print("all -----------")
        for _protoName in self._allProtoNameList:
            print("    " + _protoName)
Beispiel #20
0
 def displayJsStructure(self, folderName_: str):
     _jsCodeFolder = fileUtils.getPath(self._assetsFolderPath, folderName_)
     _filePathDict = folderUtils.getFilePathKeyValue(_jsCodeFolder, [".js"])
     for _keyName, _filePath in _filePathDict.items():
         print(_filePath)
 def analyseMoudleExports(self):
     _filePathDict = folderUtils.getFilePathKeyValue(
         self._jsFolder, [".js"])
     for _, _filePath in _filePathDict.items():
         self.analyseMoudleExportsJS(_filePath)