Skip to content

Instantly share code, notes, and snippets.

@jhjaggars
Created December 7, 2011 21:01
Show Gist options
  • Select an option

  • Save jhjaggars/1444636 to your computer and use it in GitHub Desktop.

Select an option

Save jhjaggars/1444636 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import zipfile
import fnmatch
from optparse import OptionParser
parser = OptionParser("usage: %prog archive [file]")
(options, args) = parser.parse_args()
try:
zf = zipfile.ZipFile(args[0])
try:
for file in fnmatch.filter(zf.namelist(), args[1]):
print zf.read(file)
except IndexError:
zf.printdir()
zf.close()
except Exception, e:
parser.error(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment