diff options
author | Aaron LI <aaronly.me@gmail.com> | 2016-03-31 10:57:34 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@gmail.com> | 2016-03-31 10:57:34 +0800 |
commit | c9c896dea2ba43551c4e10bd49666105449e9bd7 (patch) | |
tree | e94b73f17b2d776c2acd4c9549657f500c3dc7ce /cli/unzip-gbk.py | |
parent | 2b6cb9b655a53d43b32a8a211287c82f4f59999a (diff) | |
download | atoolbox-c9c896dea2ba43551c4e10bd49666105449e9bd7.tar.bz2 |
add all scripts/tools
Diffstat (limited to 'cli/unzip-gbk.py')
-rwxr-xr-x | cli/unzip-gbk.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/cli/unzip-gbk.py b/cli/unzip-gbk.py new file mode 100755 index 0000000..423e10f --- /dev/null +++ b/cli/unzip-gbk.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# unzip-gbk.py +# +# http://note.ninehills.info/linux-gbk.html +# + +import os +import sys +import zipfile + +print "Processing File " + sys.argv[1] + +file=zipfile.ZipFile(sys.argv[1],"r"); +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 = file.read(name) + if not os.path.exists(utf8name): + fo = open(utf8name, "w") + fo.write(data) + fo.close +file.close() |