Skip to content

Instantly share code, notes, and snippets.

@Earthcomputer
Created August 13, 2018 04:12
Show Gist options
  • Save Earthcomputer/7d977283108b49a4710a18de79f9806c to your computer and use it in GitHub Desktop.
Save Earthcomputer/7d977283108b49a4710a18de79f9806c to your computer and use it in GitHub Desktop.
Compares to JARs and filters out modified classes
from zipfile import ZipFile
import sys
if len(sys.argv) < 4:
print("python " + sys.argv[0] + " <unchanged.jar> <changed.jar> <output.jar>")
else:
with ZipFile(sys.argv[1]) as unchanged:
with ZipFile(sys.argv[2]) as changed:
with ZipFile(sys.argv[3], "w") as output:
for name in changed.namelist():
content = changed.read(name)
if name not in unchanged.namelist():
output.writestr(name, content)
elif content != unchanged.read(name):
output.writestr(name, content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment