chore: 调整部分构建脚本
This commit is contained in:
parent
a5b007eb8a
commit
47f82f3cd2
7
justfile
7
justfile
|
@ -67,12 +67,17 @@ generate-metadata: env
|
|||
with open("version", "w", encoding="utf-8") as f:
|
||||
f.write(version)
|
||||
|
||||
extract-game-data:
|
||||
rm .\kotonebot\tasks\resources\game.db
|
||||
python .\tools\db\extract_schema.py -i .\submodules\gakumasu-diff -d .\kotonebot\tasks\resources\game.db
|
||||
python .\tools\db\extract_resources.py
|
||||
|
||||
@package-resource:
|
||||
Write-Host "Packaging kotonebot-resource..."
|
||||
@{{venv}} python -m build -s kotonebot-resource
|
||||
|
||||
# Package KAA
|
||||
@package: env package-resource generate-metadata
|
||||
@package: env package-resource generate-metadata extract-game-data
|
||||
{{venv}} python tools/make_resources.py -p # Make R.py in production mode
|
||||
|
||||
Write-Host "Removing old build files..."
|
||||
|
|
|
@ -18,9 +18,7 @@ manifest = gom.fetch()
|
|||
|
||||
print("提取 P 偶像卡资源...")
|
||||
base_path = './kotonebot/tasks/resources/idol_cards'
|
||||
if os.path.exists(base_path):
|
||||
shutil.rmtree(base_path)
|
||||
os.makedirs(base_path)
|
||||
os.makedirs(base_path, exist_ok=True)
|
||||
|
||||
db = sqlite3.connect("./kotonebot/tasks/resources/game.db")
|
||||
cursor = db.execute("""
|
||||
|
@ -50,14 +48,17 @@ for row in tqdm.tqdm(cursor.fetchall()):
|
|||
path1 = base_path + f'/{skin_id}_1.png'
|
||||
if asset_id is None:
|
||||
raise ValueError(f"未找到P偶像卡资源:{skin_id} {name}")
|
||||
manifest.download(asset_id0, path=path0, categorize=False)
|
||||
manifest.download(asset_id1, path=path1, categorize=False)
|
||||
|
||||
# 转换分辨率 140x188
|
||||
img0 = cv2.imread(path0)
|
||||
img1 = cv2.imread(path1)
|
||||
assert img0 is not None and img1 is not None
|
||||
img0 = cv2.resize(img0, (140, 188), interpolation=cv2.INTER_AREA)
|
||||
img1 = cv2.resize(img1, (140, 188), interpolation=cv2.INTER_AREA)
|
||||
cv2.imwrite(path0, img0)
|
||||
cv2.imwrite(path1, img1)
|
||||
if not os.path.exists(path0):
|
||||
manifest.download(asset_id0, path=path0, categorize=False)
|
||||
# 转换分辨率 140x188
|
||||
img0 = cv2.imread(path0)
|
||||
assert img0 is not None
|
||||
img0 = cv2.resize(img0, (140, 188), interpolation=cv2.INTER_AREA)
|
||||
cv2.imwrite(path0, img0)
|
||||
if not os.path.exists(path1):
|
||||
manifest.download(asset_id1, path=path1, categorize=False)
|
||||
# 转换分辨率 140x188
|
||||
img1 = cv2.imread(path1)
|
||||
assert img1 is not None
|
||||
img1 = cv2.resize(img1, (140, 188), interpolation=cv2.INTER_AREA)
|
||||
cv2.imwrite(path1, img1)
|
||||
|
|
|
@ -204,6 +204,8 @@ class {{ class_name }}:
|
|||
|
||||
def create_sqlite_database(sql_statements: list[str], db_path: str):
|
||||
"""创建SQLite数据库并执行建表语句"""
|
||||
folder_path = os.path.dirname(db_path)
|
||||
os.makedirs(folder_path, exist_ok=True)
|
||||
with sqlite3.connect(db_path) as conn:
|
||||
for sql in sql_statements:
|
||||
if sql.strip():
|
||||
|
@ -362,12 +364,12 @@ if __name__ == "__main__":
|
|||
# 创建SQLite数据库和SQL文件
|
||||
if args.database:
|
||||
# 生成SQL文件
|
||||
sql_file_path = os.path.splitext(args.database)[0] + '.sql'
|
||||
with open(sql_file_path, 'w', encoding='utf-8') as f:
|
||||
for sql in all_sql_statements:
|
||||
if sql.strip():
|
||||
f.write(sql + ';\n\n')
|
||||
print(f"成功生成SQL文件:{sql_file_path}")
|
||||
# sql_file_path = os.path.splitext(args.database)[0] + '.sql'
|
||||
# with open(sql_file_path, 'w', encoding='utf-8') as f:
|
||||
# for sql in all_sql_statements:
|
||||
# if sql.strip():
|
||||
# f.write(sql + ';\n\n')
|
||||
# print(f"成功生成SQL文件:{sql_file_path}")
|
||||
|
||||
# 创建数据库
|
||||
create_sqlite_database(all_sql_statements, args.database)
|
||||
|
|
Loading…
Reference in New Issue