Skip to content

Instantly share code, notes, and snippets.

@Earthcomputer
Created August 13, 2018 04:12

Revisions

  1. Earthcomputer created this gist Aug 13, 2018.
    15 changes: 15 additions & 0 deletions get_changed.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    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)