""" Create any directories that don't currently exist """
for dir in directories:
curdir = os.path.join(basedir, dir)
if not os.path.exists(curdir):
os.mkdir(curdir)
continue
def _listdirs(self, file):
''' Grabs all the directories in the zip structure
This is necessary to create the structure before trying
to extract the file to it. '''
zf = zipfile.ZipFile(file)
dirs = []
for name in zf.namelist():
if name.endswith('/'):
dirs.append(name)
continue
dirs.sort()
return dirs
def usage():
print 'usage: unzip.py -z <zipfile> -o <targetdir>\n <zipfile> is the source zipfile to extract\n <targetdir> is the target destination\n\n -z zipfile to extract\n -o target location\n -p sets the percentage notification\n -v sets the extraction to verbose (overrides -p)\n\n long options also work:\n --verbose\n --percent=10\n --zipfile=<zipfile>\n --outdir=<targetdir>'