Write a file or a bytestring to a ZipFile as a separate entry and update contents_hash as a side effect.
(
archive: zipfile.ZipFile,
arcname: str,
data: bytes,
date_time: Tuple[int, int, int, int, int, int],
compression: int,
stat: Optional[os.stat_result] = None,
)
| 67 | |
| 68 | |
| 69 | def write_to_zipapp( |
| 70 | archive: zipfile.ZipFile, |
| 71 | arcname: str, |
| 72 | data: bytes, |
| 73 | date_time: Tuple[int, int, int, int, int, int], |
| 74 | compression: int, |
| 75 | stat: Optional[os.stat_result] = None, |
| 76 | ) -> None: |
| 77 | """Write a file or a bytestring to a ZipFile as a separate entry and update contents_hash as a side effect.""" |
| 78 | |
| 79 | zinfo = zipfile.ZipInfo(arcname, date_time=date_time) |
| 80 | zinfo.compress_type = compression |
| 81 | |
| 82 | if stat: |
| 83 | zinfo.external_attr = (S_IMODE(stat.st_mode) | S_IFMT(stat.st_mode)) << 16 |
| 84 | |
| 85 | archive.writestr(zinfo, data) |
| 86 | |
| 87 | |
| 88 | def rglob_follow_symlinks(path: Path, glob: str) -> Generator[Path, None, None]: |