_pack_skill.py 957 B

1234567891011121314151617181920212223242526
  1. import os, zipfile, sys
  2. SRC = os.path.expanduser('~/.workbuddy/skills/bun-report-parser')
  3. OUT = r'E:/cfc/docs/参考资料/publish/bun-report-parser-skill-v1.1.2.zip'
  4. files = []
  5. for root, dirs, fs in os.walk(SRC):
  6. dirs[:] = [d for d in dirs if d != '__pycache__']
  7. for f in fs:
  8. if f.endswith('.pyc') or '.bak' in f:
  9. continue
  10. full = os.path.join(root, f)
  11. rel = os.path.relpath(full, os.path.dirname(SRC))
  12. files.append((full, rel.replace(os.sep, '/')))
  13. with zipfile.ZipFile(OUT, 'w', zipfile.ZIP_DEFLATED) as zf:
  14. for full, rel in files:
  15. zf.write(full, rel)
  16. print('packaged', len(files), 'files ->', OUT)
  17. with zipfile.ZipFile(OUT) as zf:
  18. for n in zf.namelist():
  19. print(' ', n)
  20. bad = [n for n in zf.namelist() if '.bak' in n or n.endswith('.pyc') or '__pycache__' in n]
  21. print('DIRTY:', bad) if bad else print('CLEAN')
  22. print('size KB:', round(os.path.getsize(OUT) / 1024, 1))