Download tools/package.py from PolytechCyInstitute/cyber-range: direct link, hf CLI and curl.
- Browser
- Download file 980 Bytes
-
https://huggingface.co/PolytechCyInstitute/cyber-range/resolve/main/tools/package.py
- Command line
-
hf download hf://PolytechCyInstitute/cyber-range/tools/package.py
-
curl -L -o package.py https://huggingface.co/PolytechCyInstitute/cyber-range/resolve/main/tools/package.py
980 Bytes
| #!/usr/bin/env python3 | |
| """Create a clean, portable source package without local secrets or caches.""" | |
| from pathlib import Path | |
| from zipfile import ZIP_DEFLATED, ZipFile | |
| ROOT = Path(__file__).resolve().parents[1] | |
| OUTPUT = ROOT / "cyber-range.zip" | |
| EXCLUDED_DIRS = {".git", ".vendor", "__pycache__", ".pytest_cache", "superpowers"} | |
| EXCLUDED_FILES = {".env", OUTPUT.name} | |
| def included(path: Path) -> bool: | |
| relative = path.relative_to(ROOT) | |
| return not any(part in EXCLUDED_DIRS for part in relative.parts) and path.name not in EXCLUDED_FILES | |
| def main() -> None: | |
| files = sorted(path for path in ROOT.rglob("*") if path.is_file() and included(path)) | |
| with ZipFile(OUTPUT, "w", compression=ZIP_DEFLATED, compresslevel=9) as archive: | |
| for path in files: | |
| archive.write(path, Path("cyber-range") / path.relative_to(ROOT)) | |
| print(f"Created {OUTPUT.name}: {len(files)} files, {OUTPUT.stat().st_size:,} bytes") | |
| if __name__ == "__main__": | |
| main() | |