import-ninja.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:blender-import-ninjaripper 作者: angavrilov 项目源码 文件源码
def parse_log(self, logdir):
        logpath = self.find_log(logdir)
        if not logpath:
            return {}

        fh = open(logpath, "rt", encoding='cp437')
        try:
            stage_pattern = re.compile(r'^\S+\s+\S+\s+Texture stage #(\d+)\s.*\\([^\\]+)\\(Tex_\d+_\d+\.dds)\s*$')
            mesh_pattern = re.compile(r'^\S+\s+\S+\s+Mesh saved as:.*\\([^\\]+)\\(Mesh_\d+\.rip)\s*$')
            logtable = {}
            stage_accum = {}

            for line in fh:
                match = mesh_pattern.fullmatch(line)
                if match:
                    subdir = match.group(1).lower()
                    if subdir not in logtable:
                        logtable[subdir] = {}
                    logtable[subdir][match.group(2).lower()] = stage_accum
                    stage_accum = {}
                else:
                    match = stage_pattern.fullmatch(line)
                    if match:
                        stage_accum[int(match.group(1))] = match.group(3)

            return logtable
        finally:
            fh.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号