28 lines
969 B
Python
28 lines
969 B
Python
# -*- coding: utf-8 -*-
|
|
"""xq0085 团购数据核对 打包脚本:生成 dist-plugin/xq0085_v<版本>.zip。
|
|
|
|
用法:.venv\\Scripts\\python.exe plugins\\XQ0001-0100\\XQ0085 团购数据核对\\_pack.py
|
|
"""
|
|
import json
|
|
import os
|
|
import zipfile
|
|
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
ROOT = os.path.abspath(os.path.join(HERE, '..', '..', '..'))
|
|
OUT = os.path.join(ROOT, 'dist-plugin')
|
|
|
|
with open(os.path.join(HERE, 'plugin.json'), encoding='utf-8') as fp:
|
|
manifest = json.load(fp)
|
|
name = 'xq%s_v%s.zip' % (manifest['id'].replace('xq', ''), manifest['version'])
|
|
os.makedirs(OUT, exist_ok=True)
|
|
target = os.path.join(OUT, name)
|
|
|
|
with zipfile.ZipFile(target, 'w', zipfile.ZIP_DEFLATED) as zf:
|
|
for dirpath, _, files in os.walk(HERE):
|
|
for f in files:
|
|
if f == '_pack.py' or f.endswith('.pyc'):
|
|
continue
|
|
full = os.path.join(dirpath, f)
|
|
zf.write(full, os.path.relpath(full, HERE))
|
|
print(target)
|