From d687b125a0036913a2cfe1380abe47514750a531 Mon Sep 17 00:00:00 2001 From: Sylvain Thenault Date: Wed, 20 Aug 2008 19:35:11 +0200 Subject: new simple unzip function --- shellutils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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. -- cgit v1.2.1