author | ymh <ymh.work@gmail.com> |
Tue, 08 Jun 2010 15:31:42 +0200 | |
changeset 4 | 7c994c98d1df |
parent 0 | web/ldt/utils/zipfileext.py@ecdfc63274bf |
permissions | -rw-r--r-- |
0 | 1 |
import zipfile, os, os.path |
2 |
||
3 |
class ZipFileExt(zipfile.ZipFile): |
|
4 |
def unzip_into_dir(self, dir): |
|
5 |
if not os.path.exists(dir): |
|
6 |
os.mkdir(dir, 0777) |
|
7 |
for name in self.namelist(): |
|
8 |
if name.endswith('/'): |
|
9 |
os.mkdir(os.path.join(dir,name)) |
|
10 |
else: |
|
11 |
outfile = open(os.path.join(dir,name), 'wb') |
|
12 |
outfile.write(self.read(name)) |
|
13 |
outfile.close() |
|
14 |