Many zip archives (especially those include OS X applications) contain symlinks. When using the zipfile.extractall
method, symlinks are turned into regular files. Anyone know how to preserve them as links?
There seems to be no way to do this using the zipfile module. I solved it using the subprocess module:
from subprocess import check_output, CalledProcessError, STDOUT
try:
check_output(['unzip', '-q', my_zipfile, '-d', destination], stderr=STDOUT)
...
except CalledProcessError as err:
(use err.cmd, err.returncode and err.output to take action)
Not using the extractall method. You'll need to do it manually, probably ending with something looking something like this (except you're extracting not compressing).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With