Hi,
I am zipping a folder and an error occurred in below code which says :
==> AttributeError: 'builtin_function_or_method' object has no attribute 'tell'
zipfile.py:
def write(self, filename, arcname=None, compress_type=None):
...
zinfo.header_offset = self.fp.tell() # Start of header bytes
...
...
FYI:I have tried using "from zipfile import *" instead of "import zipfile", but of no avail.
What is causing this problem?
Regards,
Zia
My code to zip a folder:
import zipfile [B]## i've tried with "from zipfile import *"[/B]
import os
def main():
zip = "help3.zip"
directory = "C:\MYDIR"
toZip(directory)
def toZip(directory):
zippedHelp = zipfile.ZipFile(zip, "w", compression=zipfile.ZIP_DEFLATED )
zipfile.debug = 3
list = os.listdir(directory)
for entity in list:
each = os.path.join(directory,entity)
if os.path.isfile(each):
print each
print os.path.basename(each)
zippedHelp.write(each, os.path.basename(each), zipfile.ZIP_DEFLATED)
else:
addFolderToZip(zippedHelp,entity)
zippedHelp.close()
def addFolderToZip(zippedHelp,folder):
for file in folder:
if os.path.isfile(file):
zippedHelp.write(file, os.path.basename(file), zipfile.ZIP_DEFLATED)
elif os.path.isdir(file):
addFolderToZip(zippedHelp,file)
main()