示例#1
0
 def _sign_sounds(self):
     sound_list = []
     JFileUtils.find_files(self._dst_dir, sound_list, ['.mp3'])
     if len(sound_list) < 1:
         return
     author = JWords.hump(5, 10)
     print('... sign sounds, author:', author)
     JSoundsSigner.sign_sounds(sound_list, author)
示例#2
0
    def _rename_assets(self):
        # 获取文件列表
        root_dir = self._dst_dir
        file_list = []
        JFileUtils.find_files(root_dir, file_list)
        if len(file_list) < 1:
            return
        print('... renaming')

        # 生成垃圾文件夹结构
        use_junk_tree = False
        file_ext_list = None
        junks_maker = self._junks_maker
        if (self._app_filler_nums > 0) and (self._app_filler_size > 0):
            junks_maker.make_app_filler(root_dir, self._app_filler_nums, self._app_filler_size)
            use_junk_tree = True
        else:
            file_ext_list = []
            for i in range(random.randint(2, 5)):
                file_ext_list.append(JFillerHelper.rand_file_ext())

        # 重命名资源
        name_pos = len(root_dir) + 1
        name_map = {}
        for file in file_list:
            new_path = None
            if use_junk_tree :
                new_ext = junks_maker.rand_file_ext()
                new_dir = junks_maker.find_folder_by_ext(new_ext)
                new_path = new_dir.rand_child_path(new_ext)
            else:
                new_path = JFileUtils.rand_path(root_dir, random.choice(file_ext_list))
            shutil.move(file, new_path)
            new_name = new_path[name_pos:] # 保存引用索引
            if os.path.splitext(file)[1] == JPackageInfo.ASSETS_PACKAGE_EXT:
                for pi in self._assets_info.package_list:
                    if 0 == JFileUtils.compare_path(file, pi.pack_bin_path):
                        pi.pack_bin_path = new_name
                        # print('package: %s' % new_name)
                        break
            else:
                old_name = file[name_pos:]
                name_map[old_name] = new_name
        JFileUtils.delete_gap_dir(root_dir)# 删除空的文件夹
        self._assets_info.mapping_dict = name_map
        print('rename done [%d]' % len(name_map))