Created
August 24, 2012 08:19
-
-
Save mebubo/3447425 to your computer and use it in GitHub Desktop.
Find classes in jars
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
#!/usr/bin/env python | |
import sys, os | |
from zipfile import ZipFile | |
# Given a directory of jar files and a pattern, list all files that | |
# contain matching classes, and the matching classes | |
# | |
# Usage: findclass.py <dir> <pattern> | |
dir, pattern = sys.argv[1:3] | |
for filename in os.listdir(dir): | |
if filename.endswith(".jar"): | |
matches = [path for path in ZipFile(filename, "r").namelist() | |
if pattern in path] | |
if matches: | |
print "%s:" % filename | |
for m in matches: | |
print "\t%s" % m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment