diff options
author | Sylvain Thenault <sylvain.thenault@logilab.fr> | 2008-08-20 19:35:11 +0200 |
---|---|---|
committer | Sylvain Thenault <sylvain.thenault@logilab.fr> | 2008-08-20 19:35:11 +0200 |
commit | d687b125a0036913a2cfe1380abe47514750a531 (patch) | |
tree | 6cba30cf7d0a697e9db04ee4ec4710ea53ee352d /shellutils.py | |
parent | c29704aa086b0867581c9b5d89f6fecd31953076 (diff) | |
download | logilab-common-d687b125a0036913a2cfe1380abe47514750a531.tar.gz |
new simple unzip function
Diffstat (limited to 'shellutils.py')
-rw-r--r-- | shellutils.py | 14 |
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. |