Example #1
0
def cycTra_for_methodListMap(file_dir, funNamePrefix):
    fs = os.listdir(file_dir)
    for dir in fs:
        tmp_path = os.path.join(file_dir, dir)
        if not os.path.isdir(tmp_path):
            try:
                if tmp_path.endswith('.h'):
                    pass
                if not igFil.isIgnoreFiles(tmp_path):
                    if '+' not in tmp_path:
                        confusionAt_H_Obj(tmp_path, funNamePrefix)
                        conLog.info('[ConFunH OK] ' + tmp_path)
                    if tmp_path.endswith('.swift'):
                        if not igFil.isIgnoreFiles(tmp_path):
                            if '+' not in tmp_path:
                                if 'Tests.swift' not in tmp_path:
                                    confusionAt_Swift_Obj(tmp_path, funNamePrefix)
                                    conLog.info('[ConFunH OK] ' + tmp_path)
            except Exception as e:
                try:
                    conLog.error('[ConFunH Fail] ' + str(e))
                finally:
                    e = None
                    del e

        else:
            cycTra_for_methodListMap(tmp_path, funNamePrefix)
Example #2
0
def cycTraPropertyListMap(file_dir, propertyPrefix):
    fs = os.listdir(file_dir)
    for dir in fs:
        tmp_path = os.path.join(file_dir, dir)
        if not os.path.isdir(tmp_path):
            try:
                if tmp_path.endswith('.h'):
                    if not igFil.isIgnoreFiles(tmp_path):
                        pass
                if '+' not in tmp_path:
                    if 'AppDelegate.' not in tmp_path:
                        getPropertyNameAtHFile(tmp_path, propertyPrefix)
                        conLog.info('[ReadProH OK] ' + tmp_path)
                    if tmp_path.endswith('.swift'):
                        if not igFil.isIgnoreFiles(tmp_path):
                            if '+' not in tmp_path:
                                if 'AppDelegate.' not in tmp_path:
                                    getPropertyNameAtSwiftAndMiss(
                                        tmp_path, propertyPrefix)
                                    conLog.info('[ReadProH OK] ' + tmp_path)
            except Exception as e:
                try:
                    conLog.error('[ReadProH Fail] ' + str(e))
                finally:
                    e = None
                    del e

        else:
            cycTraPropertyListMap(tmp_path, propertyPrefix)
Example #3
0
def findProjectPbxproj(file_dir):
    if _projectNameTup == None:
        return
    fs = os.listdir(file_dir)
    for dir in fs:
        tmp_path = os.path.join(file_dir, dir)
        if not os.path.isdir(tmp_path):
            try:
                if tmp_path.endswith('project.pbxproj'):
                    if not igFil.isIgnoreFiles(tmp_path):
                        modifyProjectPbxproj(tmp_path)
                    if '/Pods/' in tmp_path or tmp_path.endswith('contents.xcworkspacedata'):
                        modifyProjectPbxproj(tmp_path)
                    else:
                        if '/Pods/' not in tmp_path:
                            if tmp_path.endswith('Podfile'):
                                modifyProjectPbxproj(tmp_path)
                    conLog.info('[MissProName OK] ' + tmp_path)
            except Exception as e:
                try:
                    conLog.error('[MissProName Fail] ' + str(e))
                finally:
                    e = None
                    del e
 
        else:
            findProjectPbxproj(tmp_path)
Example #4
0
def reviseFilesName(file_dir):
    fs = os.listdir(file_dir)
    for dir in fs:
        tmp_path = os.path.join(file_dir, dir)
        if not os.path.isdir(tmp_path):
            try:
                if not igFil.isIgnoreFiles(tmp_path):
                    if tmp_path.endswith('.h') or tmp_path.endswith(
                            '.m') or tmp_path.endswith(
                                '.xib') or tmp_path.endswith('.swift'):
                        for object_name in objectNamesMap.keys():
                            replace_name = objectNamesMap[object_name]
                            new_path = tmp_path.replace(
                                object_name + '.', replace_name + '.')
                            if tmp_path != new_path:
                                os.rename(tmp_path, new_path)
                                conLog.info('[ReFilNa Scu] ' + tmp_path)

            except Exception as e:
                try:
                    conLog.error('[ReFilNa Fail] ' + str(e))
                finally:
                    e = None
                    del e

        else:
            reviseFilesName(tmp_path)
Example #5
0
def getObjectNames(file_dir, prefix):
    global objectNamesMap
    object_h_list = []
    object_m_list = []
    fs = os.listdir(file_dir)
    for dir in fs:
        tmp_path = os.path.join(file_dir, dir)
        if not os.path.isdir(tmp_path):
            if '/AppDelegate.' not in tmp_path:
                if '/ViewController.' not in tmp_path:
                    if not igFil.isIgnoreFiles(tmp_path):
                        object_name = tmp_path.split('/')[-1].split('.')[0]
                        if tmp_path.endswith('.h'):
                            if '+' not in tmp_path:
                                object_h_list.append(object_name)
                        if tmp_path.endswith('.m'):
                            if '+' not in tmp_path:
                                object_m_list.append(object_name)
                        if tmp_path.endswith('.swift'):
                            if '+' not in tmp_path:
                                object_h_list.append(object_name)
                                object_m_list.append(object_name)
                        if object_name in object_h_list:
                            if object_name in object_m_list:
                                replace_name = prefix + addRandomCode.getMissObjName(
                                    object_name).replace('new', 'ZFJ')
                                objectNamesMap[object_name] = replace_name
        else:
            getObjectNames(tmp_path, prefix)
Example #6
0
def notUpdateFile(tmp_path):
    if '+' in tmp_path:
        return True
    elif '/Pods/' in tmp_path:
        return True
    elif 'AppDelegate.' in tmp_path:
        return True
    else:
        return igFil.isIgnoreFiles(tmp_path)
Example #7
0
def getMyProjectName(file_dir):
    global _projectNameTup
    fs = os.listdir(file_dir)
    for dir in fs:
        tmp_path = os.path.join(file_dir, dir)
        if os.path.isdir(tmp_path):
            if not igFil.isIgnoreFiles(tmp_path):
                if tmp_path.endswith('.xcodeproj'):
                    _projectName = tmp_path.split('/')[-1].split('.')[0]
                    personinfo = ZFJPersoninfo()
                    projectNamePreFix = personinfo.prefixMap['projectNamePreFix']
                    if len(projectNamePreFix) == 0:
                        projectNamePreFix = zfjTools.getWordFromLexicon().capitalize() + zfjTools.getWordFromLexicon().capitalize()
                _projectNameTup = (_projectName, projectNamePreFix)
                    break
                else:
                    getMyProjectName(tmp_path)
Example #8
0
def startReplaceSouName(file_dir):
    fs = os.listdir(file_dir)
    for dir in fs:
        tmp_path = os.path.join(file_dir, dir)
        if not os.path.isdir(tmp_path):
            try:
                if not igFil.isIgnoreFiles(tmp_path):
                    if '/Contents.json' not in tmp_path:
                        replaceAtFile(tmp_path)
                        conLog.info('[RepSouNa OK] ' + tmp_path)
            except Exception as e:
                try:
                    conLog.error('[RepSouNa Fail] ' + str(e))
                finally:
                    e = None
                    del e

        else:
            startReplaceSouName(tmp_path)
Example #9
0
def encryptString(file_dir):
    fs = os.listdir(file_dir)
    for dir in fs:
        tmp_path = os.path.join(file_dir, dir)
        if not os.path.isdir(tmp_path):
            try:
                if not igFil.isIgnoreFiles(tmp_path):
                    pass
                if not tmp_path.endswith('.pch'):
                    obfuscate(tmp_path)
                    conLog.info('[EncrStr OK] ' + tmp_path)
            except Exception as e:
                try:
                    conLog.error('[EncrStr Fail] ' + str(e))
                finally:
                    e = None
                    del e

        else:
            encryptString(tmp_path)
Example #10
0
def searchMissCode(file_dir):
    fs = os.listdir(file_dir)
    for dir in fs:
        tmp_path = os.path.join(file_dir, dir)
        if not os.path.isdir(tmp_path):
            try:
                if not igFil.isIgnoreFiles(tmp_path):
                    pass
                if tmp_path.endswith('.m'):
                    missCodeAtFile(tmp_path)
                    conLog.info('[SearchStr OK] ' + tmp_path)
            except Exception as e:
                try:
                    conLog.error('[SearchStr Fail] ' + str(e))
                finally:
                    e = None
                    del e

        else:
            searchMissCode(tmp_path)
Example #11
0
def startDeleteNotes(file_dir):
    fs = os.listdir(file_dir)
    for dir in fs:
        tmp_path = os.path.join(file_dir, dir)
        if not os.path.isdir(tmp_path):
            try:
                if not igFil.isIgnoreFiles(tmp_path):
                    if tmp_path.endswith('.h') or tmp_path.endswith(
                            '.m') or tmp_path.endswith(
                                '.mm') or tmp_path.endswith(
                                    '.swift') or tmp_path.endswith('.pch'):
                        readFileEveryLine(tmp_path)
                        conLog.info('[DelNote OK] ' + tmp_path)
            except Exception as e:
                try:
                    conLog.error('[DelNote Fail] ' + str(e))
                finally:
                    e = None
                    del e

        else:
            startDeleteNotes(tmp_path)
Example #12
0
def startUpdateSourceHash(file_dir):
    fs = os.listdir(file_dir)
    for dir in fs:
        tmp_path = os.path.join(file_dir, dir)
        if not os.path.isdir(tmp_path):
            try:
                if not igFil.isIgnoreFiles(tmp_path):
                    if isImage(tmp_path):
                        old_hash = getFileHash(tmp_path)
                        updateImgHash(tmp_path)
                        new_hash = getFileHash(tmp_path)
                        conLog.info('[UPdHash OK] ' + tmp_path)
                        conLog.tips('[UPdHash Meg] Old:' + old_hash +
                                    '<->New:' + new_hash)
            except Exception as e:
                try:
                    conLog.error('[UPdHash Fail] ' + str(e))
                finally:
                    e = None
                    del e

        else:
            startUpdateSourceHash(tmp_path)
Example #13
0
def searchXcassets(file_dir, imgPreFix):
    global sourceTypeMap
    global xcassetsMap
    fs = os.listdir(file_dir)
    for dir in fs:
        tmp_path = os.path.join(file_dir, dir)
        if os.path.isdir(tmp_path):
            pass
        if tmp_path.endswith('.imageset'):
            try:
                if not igFil.isIgnoreFiles(tmp_path):
                    imgArr = saveNameToMap(tmp_path, imgPreFix)
                    new_path = tmp_path.replace(imgArr[0] + '.imageset',
                                                imgArr[1] + '.imageset')
                    if tmp_path != new_path:
                        os.rename(tmp_path, new_path)
                        conLog.info('[SeaXcas Scu] ' + tmp_path)
                        searchXcassets(new_path, imgPreFix)
            except Exception as e:
                try:
                    conLog.error('[SeaXcas Fail] ' + str(e))
                    searchXcassets(tmp_path, imgPreFix)
                finally:
                    e = None
                    del e

        elif not os.path.isdir(tmp_path):
            if '.xcassets' in tmp_path:
                if isImage(tmp_path):
                    imageType = '.' + tmp_path.split('.')[-1]
                    fatherPath = '/'.join(tmp_path.split('/')[:-1])
                    imageName = tmp_path.split('/')[-1].split('.')[0]
                    newImgName = imgPreFix + zfjTools.getWordFromLexicon(
                    ) + zfjTools.getWordFromLexicon().capitalize()
                    new_path = tmp_path.replace('/' + imageName + imageType,
                                                '/' + newImgName + imageType)
                    os.rename(tmp_path, new_path)
                    partMap = {}
                    if fatherPath in xcassetsMap.keys():
                        partMap = xcassetsMap[fatherPath]
                    partMap[imageName] = newImgName
                    xcassetsMap[fatherPath] = partMap
        elif not os.path.isdir(tmp_path):
            if isNeedMissImg(tmp_path):
                if not igFil.isIgnoreFiles(tmp_path):
                    imageName = tmp_path.strip().split('/')[-1]
                    imageType = ''
                    if '@' in imageName:
                        nameList = imageName.split('@')
                        imageName = nameList[0]
                        imageType = '@' + nameList[-1]
                    else:
                        nameList = imageName.split('.')
                        imageName = nameList[0]
                        imageType = '.' + nameList[-1]
                    if imageName not in sourceMap.keys():
                        newImgName = imgPreFix + zfjTools.getWordFromLexicon(
                        ) + zfjTools.getWordFromLexicon().capitalize()
                        sourceMap[imageName] = newImgName
                    else:
                        newImgName = sourceMap[imageName]
                    if imageName in sourceTypeMap.keys():
                        old_imageType = sourceTypeMap[imageName]
                        if old_imageType != imageType:
                            old_imageType += ',' + imageType
                            sourceTypeMap[imageName] = old_imageType
                        else:
                            sourceTypeMap[imageName] = imageType
                        new_path = tmp_path.replace(imageName, newImgName)
                        os.rename(tmp_path, new_path)
                        conLog.info('[SeaXcas Scu] ' + tmp_path)
        else:
            if os.path.isdir(tmp_path):
                searchXcassets(tmp_path, imgPreFix)