Skip to content

Instantly share code, notes, and snippets.

@AllanChain
Created September 22, 2021 15:08
Show Gist options
  • Save AllanChain/e29e53dbe5b44397862da11e0893001e to your computer and use it in GitHub Desktop.
Save AllanChain/e29e53dbe5b44397862da11e0893001e to your computer and use it in GitHub Desktop.
pkuphysu code zipper (legacy)
from pathlib import Path
from zipfile import ZipFile
PROJECT_ROOT = Path(__file__).parent.parent
SRC_ROOT = PROJECT_ROOT / "src"
DIST_ROOT = SRC_ROOT / "dist"
DIST_ZIP = DIST_ROOT / "output.zip"
FILE_INCLUDE = ["pkuphysu_wechat/**/*", "*.py", "bootstrap"]
FILE_NAME_EXCLUDE = [".secrets.local.toml"]
DIST_ROOT.mkdir(exist_ok=True)
zf = ZipFile(DIST_ZIP, "w")
for pattern in FILE_INCLUDE:
for file in SRC_ROOT.glob(pattern):
if file.name not in FILE_NAME_EXCLUDE:
zf.write(file, file.relative_to(SRC_ROOT))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment