Created
March 8, 2011 14:32
-
-
Save sergeytunnik/860331 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os | |
import sys | |
import zipfile | |
filename = 'list.txt' | |
archname = 'desktop.zip' | |
outdir = os.path.curdir | |
inputset = set() | |
if len(sys.argv) != 3: | |
print "Usage: zip.py /path/to/file.zip /output/dirname/" | |
sys.exit() | |
archname = sys.argv[1] | |
outdir = sys.argv[2] | |
for line in open(filename): | |
inputset.add(line.strip('\r\n')) | |
if zipfile.is_zipfile(archname): | |
arch = zipfile.ZipFile(archname, 'r') | |
else: | |
print '%s not a zip file' % archname | |
sys.exit() | |
if not os.path.exists(outdir): | |
print "Cant find output dir: %s" % outdir | |
sys.exit() | |
for info in arch.infolist(): | |
if info.filename in inputset: | |
arch.extract(info, outdir) | |
print 'ok - %s' % os.path.join(outdir, info.filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment