''' This class use for Unzip a tar file ''' import os import tarfile import sys class UnZipFolder(): def __init__(self, location): self.location=location # Set output directory here self.outputLocation="C:/" def decompress(self): try: if os.path.exists(self.location): decompressTar = tarfile.open(self.location) decompressTar.extractall(self.outputLocation) decompressTar.close() print "Extracted" else: print "No Such Folder" except: print str(sys.exc_info()) if __name__=='__main__': # Set input directory here location="C:/test.tar" unZipFolder=UnZipFolder(location) unZipFolder.decompress()
Thursday, August 26, 2010
Python Unzip a tar file
Posted by
Abu Zahed Jony
at
6:01 PM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
Object-oriented programming,
Zip/Unzip
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment