MCPcopy
hub / github.com/linkedin/shiv / write_to_zipapp

Function write_to_zipapp

src/shiv/builder.py:69–85  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

67
68
69def 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
88def rglob_follow_symlinks(path: Path, glob: str) -> Generator[Path, None, None]:

Callers 1

create_archiveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected