Created
September 22, 2021 15:08
-
-
Save AllanChain/e29e53dbe5b44397862da11e0893001e to your computer and use it in GitHub Desktop.
pkuphysu code zipper (legacy)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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