Exemple #1
0
    def menufuncDetectNonAnsiLub(self):
        '''
        扫描整个 Patches 目录下的 lub 文件
        检测他们的文件编码, 并列出非 ANSI 编码的文件
        '''
        patchesDir = self.leeCommon.patches()
        allowANSI = [
            'ASCII', 'EUC-KR', 'LATIN1', 'GBK', 'GB2312', 'CP949',
            'ISO-8859-1', 'WINDOWS-1252'
        ]

        print('正在扫描, 可能会花几分钟时间, 请耐心等待...')
        print('')
        work_start = timeit.default_timer()

        for dirpath, _dirnames, filenames in os.walk(patchesDir):
            for filename in filenames:
                fullpath = os.path.normpath('%s/%s' % (dirpath, filename))
                if not filename.lower().endswith('.lub'):
                    continue

                result, encoding = LeeLua().getLubEncoding(fullpath)
                if result and encoding not in allowANSI:
                    print('%s - %s' %
                          (encoding, os.path.relpath(fullpath, patchesDir)))

        work_elapsed = (timeit.default_timer() - work_start)

        print('扫描并检测完毕, 耗时: %0.2f 秒' % work_elapsed)
        print('')
Exemple #2
0
    def menufuncDetectLubCompiled(self):
        '''
        扫描整个 Patches 目录下的 lub 文件
        检测他们的是否已经被反编译, 并将没有被反编译的 lub 文件列出
        '''
        patchesDir = self.leeCommon.patches()

        print('正在扫描, 可能会花几分钟时间, 请耐心等待...')
        print('')
        work_start = timeit.default_timer()

        for dirpath, _dirnames, filenames in os.walk(patchesDir):
            for filename in filenames:
                fullpath = os.path.normpath('%s/%s' % (dirpath, filename))
                if not filename.lower().endswith('.lub'):
                    continue

                if LeeLua().isTrulyLubFile(fullpath):
                    print('尚未反编译 - %s' %
                          (os.path.relpath(fullpath, patchesDir)))

        work_elapsed = (timeit.default_timer() - work_start)

        print('扫描并检测完毕, 耗时: %0.2f 秒' % work_elapsed)
        print('')
Exemple #3
0
    def menufuncBatchAmendmentsLub(self):
        '''
        将 Patches 目录下的 lub 文件批量进行整理
        '''
        patchesDir = self.leeCommon.patches()

        for dirpath, _dirnames, filenames in os.walk(patchesDir):
            for filename in filenames:
                fullpath = os.path.normpath('%s/%s' % (dirpath, filename))
                if not filename.lower().endswith('.lub'):
                    continue
                if LeeLua().isTrulyLubFile(fullpath):
                    continue
                if not LeeLua().lubAmendments(fullpath, fullpath):
                    self.leeCommon.exitWithMessage('整理 %s 时发生错误, 请确认.' %
                                                   fullpath)
                else:
                    print('已整理: %s' % os.path.relpath(fullpath, patchesDir))
Exemple #4
0
    def menufuncBatchDecompileLub(self, lubSourceDirectory):
        '''
        将某个目录下的 lub 文件批量反编译
        需要让用户来选择这个目录的所在位置, 而不是一个固定位置
        '''
        print('您指定的目录为: %s' % lubSourceDirectory)

        if not self.leeCommon.isDirectoryExists(lubSourceDirectory):
            self.leeCommon.exitWithMessage('很抱歉, 你指定的目录不存在, 程序终止')

        if lubSourceDirectory.endswith('/') or lubSourceDirectory.endswith(
                '\\'):
            lubSourceDirectory = lubSourceDirectory[:-1]

        lubOutputDirectory = '%s%s%s' % (
            os.path.dirname(lubSourceDirectory), os.path.sep,
            os.path.basename(lubSourceDirectory) + '_output')
        print('计划的输出目录: %s' % lubOutputDirectory)

        if self.leeCommon.isDirectoryExists(lubOutputDirectory):
            self.leeCommon.exitWithMessage('发现输出目录已经存在, 请先手动删除后重试..')

        print('')
        LeeLua().decodeDir(lubSourceDirectory, lubOutputDirectory)