summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Thenault <sylvain.thenault@logilab.fr>2008-08-20 19:35:11 +0200
committerSylvain Thenault <sylvain.thenault@logilab.fr>2008-08-20 19:35:11 +0200
commitd687b125a0036913a2cfe1380abe47514750a531 (patch)
tree6cba30cf7d0a697e9db04ee4ec4710ea53ee352d
parentc29704aa086b0867581c9b5d89f6fecd31953076 (diff)
downloadlogilab-common-d687b125a0036913a2cfe1380abe47514750a531.tar.gz
new simple unzip function
-rw-r--r--shellutils.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/shellutils.py b/shellutils.py
index b8b2cda..f6072f1 100644
--- a/shellutils.py
+++ b/shellutils.py
@@ -141,6 +141,20 @@ def find(directory, exts, exclude=False, blacklist=STD_BLACKLIST):
return files
+def unzip(archive, destdir):
+ import zipfile
+ if not exists(destdir):
+ os.mkdir(destdir)
+ zfobj = zipfile.ZipFile(archive)
+ for name in zfobj.namelist():
+ if name.endswith('/'):
+ os.mkdir(join(destdir, name))
+ else:
+ outfile = open(join(destdir, name), 'wb')
+ outfile.write(zfobj.read(name))
+ outfile.close()
+
+
class Execute:
"""This is a deadlock safe version of popen2 (no stdin), that returns
an object with errorlevel, out and err.