Working directory sorununu asmak icin bir wrapper fonksiyon ekleyelim..

Simdi testleri gozden gecirecegiz, hala calismiyor lakin korkmaya gerek yok.
This commit is contained in:
A. Murat Eren
2005-06-24 13:24:31 +00:00
parent 9eccf1b2c2
commit 652138d995
+10 -1
View File
@@ -77,11 +77,20 @@ class ArchiveZip(ArchiveBase):
self.zip.close()
def add_to_archive(self, fileName):
"""A wrapper function to handle working directory sh*t"""
cwd = os.getcwd()
pathName = os.path.dirname(fileName)
fileName = os.path.basename(fileName)
os.chdir(pathName)
self.add_file(fileName)
os.chdir(cwd)
def add_file(self, fileName):
"""Add file or directory to a zip file"""
if os.path.isdir(fileName) and not os.path.islink(fileName):
self.zip.writestr(fileName + '/', '')
for f in os.listdir(fileName):
self.add_to_archive(fileName + '/' + f)
self.add_file(fileName + '/' + f)
else:
if os.path.islink(fileName):
dest = os.readlink(fileName)