By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,813 Members | 1,121 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,813 IT Pros & Developers. It's quick & easy.

zipfile + symlink..

P: n/a


I have a problem about zipfile.

I'm trying to add files from local file system into a zip file via zipfile
module of python.. I have a function in my class which recursively adds files
or dirs into zip:

def add_file(self, fileName):
"""add file or directory to a zip file"""
if os.path.isdir(fileName): + '/', '')
for f in os.listdir(fileName):
self.add_file(fileName + '/' + f)
if os.path.islink(fileName):
dest = os.readlink(fileName), dest)
#do something here to set 'fileName's attributes
#to write it as a symlink into the zip
else:, fileName, zipfile.ZIP_DEFLATED)

But here is a problem raising for symlinks (at the commented section of the
code passage).. If i don't perform any special process for symlinks in the
function, function produces zip files without symlinks, naturally; symlinks
become regular files with the 'dest' content.. I have to set the attribute of
the symlinks in the zip to make them a real symlink for the 'dest', how cani
do that?

Any help or idea would be great..
Best regards,

- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
A. Murat Eren
meren at
7BCD A5A1 8101 0F6D 84A4 BD11 FE46 2B92 527D 7293
- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -

Alan Cox sounds as if he hasn't followed the
development of programming languages
and compilers for the last 10 years (exa).

Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQBCux71/kYrklJ9cpMRAiBjAKC7ckNKc2stHI2w8c9aIWAE9DDWEACfcGH j

Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.