Skip to content

Instantly share code, notes, and snippets.

@obfusk
Last active April 11, 2024 19:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obfusk/25a2c5c43734b80465980a38af8c31df to your computer and use it in GitHub Desktop.
Save obfusk/25a2c5c43734b80465980a38af8c31df to your computer and use it in GitHub Desktop.
create a ZIP file with two CD entries pointing to the same file
#!/usr/bin/python3
import sys
import zipfile
# Usage: zipdup.py ZIPFILE ENTRY_NAME ENTRY_DATA
zfile, zentry, data = sys.argv[1:]
with zipfile.ZipFile(zfile, "w") as zf:
info = zipfile.ZipInfo(filename=zentry)
zf.writestr(info, data)
zf.filelist.append(info)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment