mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 12:47:58 +03:00
29 lines
659 B
Python
Executable file
29 lines
659 B
Python
Executable file
#!/usr/bin/env python3
|
|
import argparse
|
|
import json
|
|
import struct
|
|
import zlib
|
|
from pathlib import Path
|
|
|
|
import bson
|
|
|
|
|
|
def parse_args() -> argparse.Namespace:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("path", type=Path)
|
|
return parser.parse_args()
|
|
|
|
|
|
def main() -> None:
|
|
args = parse_args()
|
|
with args.path.open("rb") as handle:
|
|
magic = handle.read(4)
|
|
version, compressed_size, uncompressed_size = struct.unpack(
|
|
"III", handle.read(12)
|
|
)
|
|
data = bson.loads(zlib.decompress(handle.read(uncompressed_size)))
|
|
print(json.dumps(data, indent=4))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|