summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Thenault <sylvain.thenault@logilab.fr>2008-08-20 19:36:38 +0200
committerSylvain Thenault <sylvain.thenault@logilab.fr>2008-08-20 19:36:38 +0200
commit1530f6a9ef48332b1f096c0a0e560bb29ec1f25f (patch)
tree3d21949c5651e8efdadda2ae0db18bafd736ee7b
parent11dd4a14af28554de410701b391d27fa69c80c70 (diff)
parentfa1c9fb37aa69db24a9cd4a9a1001427490e6d2d (diff)
downloadlogilab-common-1530f6a9ef48332b1f096c0a0e560bb29ec1f25f.tar.gz
merge
-rw-r--r--ChangeLog10
-rw-r--r--shellutils.py14
2 files changed, 21 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 1420590..e4fd72c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,16 @@
ChangeLog for logilab.common
============================
+ --
+ * shellutils: new simple unzip function
+
2008-08-07 -- 0.34.0
- * changelog propertly adds new line at the end of each entry
+ * changelog: properly adds new line at the end of each entry
- * add a with_tempdir decorator ensuring all temporary files and dirs are removed
+ * testlib: add a with_tempdir decorator ensuring all temporary files and dirs are removed
- * improve DotBackend configuration. graphiz rendered can now be selected and additionnal graph parameter used
+ * graph: improve DotBackend configuration. graphiz rendered can now be selected
+ and additionnal graph parameter used
* db: support of Decimal Type
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.