Skip to content

Instantly share code, notes, and snippets.

@skarllot
Created August 8, 2018 01:34
Show Gist options
  • Save skarllot/b5d64cb06cdd6dcfe5ea9d6744fca8f5 to your computer and use it in GitHub Desktop.
Save skarllot/b5d64cb06cdd6dcfe5ea9d6744fca8f5 to your computer and use it in GitHub Desktop.
Pipes the content of GZipped Tar file to a Zip file without temporary files
#!/usr/bin/python
import sys
import tarfile
import zipfile
tarf = tarfile.open(sys.argv[1], "r:*")
zipf = zipfile.ZipFile(sys.argv[2], "w", zipfile.ZIP_DEFLATED, allowZip64 = True)
for m in tarf:
if m.isreg():
zipf.writestr(m.path, tarf.extractfile(m).read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment