Commits

Yusuke MURAOKA committed a3fb5fd

become zipe

  • Participants
  • Parent commits 33adfe0

Comments (0)

Files changed (1)

File scripts/unzip-sjis

-#!/usr/bin/env python
-import argparse
-import os
-import sys
-import zipfile as zf
-
-
-def main(argv=sys.argv):
-    parser = argparse.ArgumentParser(
-                        description="Unzipper for Fxxking sjis filename")
-    parser.add_argument('zip_file', metavar='ZIP_FILE',
-                        help="The ZIP archive")
-    parser.add_argument('entries', nargs='*', metavar='ENTRY',
-                        help="Specify file entries in the archive to extract")
-    parser.add_argument('-l', '--list', action='store_true',
-                        help="List entries instead of extracting")
-    parser.add_argument('-P', '--password',
-                        help="Enter password for encrypted")
-    args = parser.parse_args(argv[1:])
-
-    with zf.ZipFile(args.zip_file) as z:
-        if args.password:
-            z.setpassword(args.password)
-
-        for zinfo in z.infolist():
-            file_name = zinfo.filename.decode('sjis').encode('utf-8')
-
-            if args.list:
-                print("%d\t%d/%d/%d %d:%d:%d\t%s" %
-                      ((zinfo.file_size,) + zinfo.date_time + (file_name,)))
-                continue
-
-            if args.entries and file_name not in args.entries:
-                continue
-
-            # mkdir -p
-            dir_name = os.path.dirname(file_name)
-            try:
-                os.makedirs(dir_name)
-            except os.error:
-                pass
-
-            if not file_name.endswith('/'):
-                bin = z.read(zinfo)
-                with open(file_name, 'wb') as f:
-                    f.write(bin)
-
-
-if __name__ == '__main__':
-    main()