#!/usr/bin/env python
# -*- coding: utf-8 -*-
# uzip_gbk.py
import os
import sys
import argparse
import zipfile
parser = argparse.ArgumentParser(description='Unzip zip
file.')
parser.add_argument('file', nargs='+', help='zip file')
parser.add_argument('-p', '--password', help='set
password')
args = parser.parse_args()
zip_file = args.file[0]
password = args.password
print "Processing File " + zip_file
file=zipfile.ZipFile(zip_file, "r")
if password != None:
file.setpassword(password)
for name in file.namelist():
utf8name=name.decode('gbk')
print "Extracting " + utf8name
pathname = os.path.dirname(utf8name)
if not os.path.exists(pathname) and pathname!= "":
os.makedirs(pathname)
data = "">
if not os.path.exists(utf8name):
fo = open(utf8name, "w")
fo.write(data)
fo.close
file.close()