aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/extract_asrc.py
blob: 9b9c740066063a3aae9020f6317a819516edc159 (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
28
import argparse
import os
import sys
import tarfile


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

    return parser.parse_args()


def main():
    args = parse_args()

    for asrc in [x for x in args.input if x.endswith('.asrc') and os.path.exists(x)]:
        with tarfile.open(asrc, 'r') as tar:
            if sys.version_info >= (3, 12):
                tar.extractall(path=args.output, filter='data')
            else:
                tar.extractall(path=args.output)



if __name__ == '__main__':
    main()