473,750 Members | 2,190 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

zipfile + symlink..


Hi,

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:

-------8<-------------------8<--------------------8<------------------8<-----
def add_file(self, fileName):
"""add file or directory to a zip file"""
if os.path.isdir(f ileName):
self.zip.writes tr(fileName + '/', '')
for f in os.listdir(file Name):
self.add_file(f ileName + '/' + f)
else:
if os.path.islink( fileName):
dest = os.readlink(fil eName)
self.zip.writes tr(fileName, dest)
#do something here to set 'fileName's attributes
#to write it as a symlink into the zip
else:
self.zip.write( fileName, fileName, zipfile.ZIP_DEF LATED)
------->8------------------->8-------------------->8------------------>8-----

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 uludag.org.tr
http://cekirdek.uludag.org.tr/~meren/
0x527D7293,
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).
-

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQBCux71/kYrklJ9cpMRAiBj AKC7ckNKc2stHI2 w8c9aIWAE9DDWEA CfcGHj
eEo0EK+ueCZ1FsL 60BahYTc=
=hCiJ
-----END PGP SIGNATURE-----

Jul 19 '05 #1
0 1861

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4493
by: marco | last post by:
Hi all, I know about os.symlink(src, dst), but is there a way to overwrite an existing symlink e.g. "ln -sf"? Short of checking and, if necessary, having to delete the existing link by hand... Thanks! --
1
4214
by: Waitman Gobble | last post by:
Hello, I am new to Python. I am having trouble with zipfile.py. On a Linux machine with python 2.4.2 I have trouble opening a zipfile. Python is complaining about the bit where it does a seek(-22,2). Looks to me like zipfile.py is trying to come back 22 bytes from the end of file. # python
5
2452
by: Waguy | last post by:
Hi all, I am new to python and want to create a process to unzip large numbers of zip files I get from a SOAP application. The files all have a ZIP extention and can be unzipped using WinZip. However when I try opening the files using zlib or zipfile modules I get the following error: Traceback (most recent call last):
1
2272
by: | last post by:
I'm developing a website (PHP/Apache), and I need to be able to use a 'symlink' inside a URL where the symlink is a folder not a file. I have been able to use symlinks that point directly to a file. Now I need to be able to have the symlink point to a folder (which is a parent to other content). I have used PHP code to generate a SYMLINK to a folder, and I have successfully tested the symlink through PUTTY. What I can't seem to do is...
3
4888
bvdet
by: bvdet | last post by:
Following is an example that may provide a solution to you: """ Function makeArchive is a wrapper for the Python class zipfile.ZipFile 'fileList' is a list of file names - full path each name 'archive' is the file name for the archive with a full path """ import zipfile, os def makeArchive(fileList, archive):
8
3942
by: =?utf-8?B?5Lq66KiA6JC95pel5piv5aSp5rav77yM5pyb5p6B | last post by:
I made a C/S network program, the client receive the zip file from the server, and read the data into a variable. how could I process the zipfile directly without saving it into file. In the document of the zipfile module, I note that it mentions the file-like object? what does it mean? class ZipFile( file]]) Open a ZIP file, where file can be either a path to a file (a string) or a file-like object.
3
4221
by: towers | last post by:
Hi I'm probably doing something stupid but I've run into a problem whereby I'm trying to add a csv file to a zip archive - see example code below. The csv just has several rows with carriage return line feeds (CRLF). However after adding it to an archive and then decompressing the line endings have been converted to just line feeds (LF).
5
5165
by: Neil Crighton | last post by:
I'm using the zipfile library to read a zip file in Windows, and it seems to be adding too many newlines to extracted files. I've found that for extracted text-encoded files, removing all instances of '\r' in the extracted file seems to fix the problem, but I can't find an easy solution for binary files. The code I'm using is something like: from zipfile import Zipfile z = Zipfile(open('zippedfile.zip'))
1
2190
by: John Machin | last post by:
On Jun 4, 8:06 pm, jwesonga <crazylun...@gmail.comwrote: Nothing is ever as it seems. Let's try to work backwards from the error message ... and we don't need your magnificent script, just the traceback will do for now, so: The error says that you are trying to seek 22 bytes backwards from the
0
9000
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9577
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9339
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6081
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4713
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2804
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.