Created
October 17, 2018 04:26
-
-
Save dyno/a7fd7d062de9ba2a112b39882c39bd07 to your computer and use it in GitHub Desktop.
Print out java class path to jars that contains it
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
spark_jars = "file://x.jar,file://y.jar" | |
jars = spark_jars.split(",") | |
from zipfile import ZipFile | |
from pathlib import Path | |
from collections import defaultdict | |
from pprint import pprint | |
libs = defaultdict(set) | |
for jar in sorted(jars): | |
namelist = ZipFile(jar[7:]).namelist() | |
for name in namelist: | |
if name.endswith(".class"): | |
path = Path(name).parent | |
class_path = str(path).replace("/", ".") | |
libs[class_path].add(jar) | |
for class_path, jars in sorted(libs.items()): | |
print(class_path, end=" => ") | |
print(" # ".join(jars)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment