aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/link_jsrc.py
blob: feae72fe4e342df3fd3027dc63397d63eaef2504 (plain) (blame)
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
27
import argparse
import tarfile


def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument('--input', nargs='*')
    parser.add_argument('--output', required=True)

    return parser.parse_args()


def main():
    args = parse_args()

    with tarfile.open(args.output, 'w') as dest:
        for jsrc in [j for j in args.input if j.endswith('.jsrc')]:
            with tarfile.open(jsrc, 'r') as src:
                for item in [m for m in src.getmembers() if m.name != '']:
                    if item.isdir():
                        dest.addfile(item)
                    else:
                        dest.addfile(item, src.extractfile(item))


if __name__ == '__main__':
    main()