Skip to content

Commit

Permalink
修改release脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
gaboolic committed Aug 11, 2024
1 parent 92879bc commit ee17bb7
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 39 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ sync/
# 用户词库(自动调频, 生成的文件)
*.userdb/

*.zip
/rime-sentence-schemas/

# 用户自定义配置
*.custom.yaml
*.custom.*
Expand Down
39 changes: 0 additions & 39 deletions moqi.extended.dict.yaml

This file was deleted.

44 changes: 44 additions & 0 deletions program/release/generate_rime_all_schema_zip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import zipfile
import os

def zip_folders_and_files(zip_name, folders, files):
"""
将指定的多个文件夹和文件打包成一个ZIP文件。
:param zip_name: 输出的ZIP文件名
:param folders: 要打包的文件夹名列表
:param files: 要打包的文件名列表
"""
with zipfile.ZipFile(zip_name, 'w', zipfile.ZIP_DEFLATED) as zipf:
# 添加文件夹
for folder in folders:
for root, dirs, files_in_folder in os.walk(folder):
for file in files_in_folder:
file_path = os.path.join(root, file)
arcname = os.path.relpath(file_path, os.path.dirname(folder))
zipf.write(file_path, arcname)

# 添加文件
for file in files:
if os.path.isfile(file):
zipf.write(file, os.path.basename(file))

# todo
remove_list = ['cn_dicts_dazhu','cn_dicts_temp','others','program','recipes','./','build','sync','.DS_Store','frost_dict_for_fcitx5.txt']
folders = []
# 使用 os 模块中的 listdir 函数列出指定文件夹中的所有文件和子目录
files = []
file_names = os.listdir("./")
# 打印出所有找到的文件名
for file_name in file_names:
print(file_name)
if file_name not in remove_list and '.userdb' not in file_name and '.git' not in file_name and '.idea' not in file_name and '.zip' not in file_name and 'custom.' not in file_name:
if os.path.isdir(os.path.join("./", file_name)):
folders.append(file_name)
else:
files.append(file_name)

print(folders)
print(files)

zip_folders_and_files('rime-sentence-schemas.zip', folders, files)

0 comments on commit ee17bb7

Please sign in to comment.