forked from klensy/wt-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wrpl_unpacker.py
27 lines (19 loc) · 894 Bytes
/
wrpl_unpacker.py
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 os.path
import argparse
from formats.wrpl_parser import wrpl_file, simple_blk_build
def unpack(data, filename):
parsed = wrpl_file.parse(data)
# dirty hack, till i discover how to do it right
open(os.path.splitext(filename)[0] + '.' + 'm_set.blk', 'wb').write(simple_blk_build(parsed.m_set))
open(os.path.splitext(filename)[0] + '.' + 'rez.blk', 'wb').write(simple_blk_build(parsed.rez))
open(os.path.splitext(filename)[0] + '.' + 'wrplu', 'wb').write(parsed.wrplu.decompressed_body)
def main():
parser = argparse.ArgumentParser(description="Unpacks wrpl replays to wrplu data file and blk files")
parser.add_argument('filename', help="unpack from")
parse_result = parser.parse_args()
filename = parse_result.filename
with open(filename, 'rb') as f:
data = f.read()
unpack(data, filename)
if __name__ == '__main__':
main()