From bf9bf16ddd80182d6db233a73937215d38667dec Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Fri, 17 Feb 2023 02:58:33 +0000 Subject: [PATCH] Add ability to decompress binary files before decoding them. --- bemani/utils/binutils.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bemani/utils/binutils.py b/bemani/utils/binutils.py index c41e22d..86680fd 100644 --- a/bemani/utils/binutils.py +++ b/bemani/utils/binutils.py @@ -2,6 +2,7 @@ import argparse import sys from bemani.protocol.binary import BinaryEncoding +from bemani.protocol.lz77 import Lz77 def main() -> None: @@ -16,6 +17,13 @@ def main() -> None: default=None, required=True, ) + parser.add_argument( + "-c", + "--compressed", + help="File data is compressed with LZ77.", + action="store_true", + default=False, + ) args = parser.parse_args() if args.infile == "-": @@ -26,6 +34,9 @@ def main() -> None: packet = myfile.read() myfile.close() + if args.compressed: + packet = Lz77().decompress(packet) + benc = BinaryEncoding() filexml = benc.decode(packet) print(filexml)