Skip to content

Instantly share code, notes, and snippets.

@hideaki-t
Created May 18, 2014 07:34
Show Gist options
  • Save hideaki-t/c42a16189dd5f88a955d to your computer and use it in GitHub Desktop.
Save hideaki-t/c42a16189dd5f88a955d to your computer and use it in GitHub Desktop.

Revisions

  1. hideaki-t created this gist May 18, 2014.
    21 changes: 21 additions & 0 deletions unzip.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    import zipfile
    import sys
    from pathlib import Path


    def unzip(f, encoding, v):
    with zipfile.ZipFile(f) as z:
    for i in z.namelist():
    n = Path(i.encode('cp437').decode(encoding))
    if v:
    print(n)
    if i[-1] == '/':
    if not n.exists():
    n.mkdir()
    else:
    with n.open('wb') as w:
    w.write(z.read(i))

    if __name__ == '__main__':
    for i in sys.argv[1:]:
    unzip(i, 'cp932', 1)