blob: f774764087bcb36bc274d9735a85418f320b2401 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/usr/bin/env python3
"""Merges several .srcjar files."""
import argparse
import zipfile
def _main():
parser = argparse.ArgumentParser(description="Merge several .srcjar files")
parser.add_argument("--output", type=argparse.FileType("wb"),
help="The path of the output .srcjar")
parser.add_argument("srcjar", metavar="SRCJAR", type=argparse.FileType("rb"),
nargs="+",
help="The path of the .srcjar files to merge")
args = parser.parse_args()
with zipfile.ZipFile(args.output, "w") as output:
for srcjar_path in args.srcjar:
with zipfile.ZipFile(srcjar_path, "r") as srcjar:
for path in srcjar.namelist():
output.writestr(path, srcjar.read(path))
if __name__ == "__main__":
_main()
|