INNER CODE UNIT · Python

strip

pgbouncer/pgbouncer · win32/make-zip.py:72

def strip(path, strip_prog, tmpdir):
    """Return the path of a stripped copy of path, made in tmpdir."""
    stripped = os.path.join(tmpdir, os.path.basename(path))
    subprocess.run([strip_prog, "-o", stripped, path], check=True)
    return stripped


def add(zf, prefix, path, name=None, text=False):
    """Store path in the archive as prefix/name, converting text to CRLF."""
    info = zipfile.ZipInfo.from_file(path, f"{prefix}/{name or os.path.basename(path)}")
    info.compress_type = zipfile.ZIP_DEFLATED
    # Bit 0 of the internal attributes marks an entry as text.
    info.internal_attr = 1 if text else 0
    with open(path, "rb") as f:
        data = f.read()
    if text:
        data = EOL_RE.sub(b"\r\n", data)
    zf.writestr(info, data)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…