Add ability to decompress binary files before decoding them.
This commit is contained in:
parent
af5b6fbe0d
commit
bf9bf16ddd
@ -2,6 +2,7 @@ import argparse
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from bemani.protocol.binary import BinaryEncoding
|
from bemani.protocol.binary import BinaryEncoding
|
||||||
|
from bemani.protocol.lz77 import Lz77
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
@ -16,6 +17,13 @@ def main() -> None:
|
|||||||
default=None,
|
default=None,
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-c",
|
||||||
|
"--compressed",
|
||||||
|
help="File data is compressed with LZ77.",
|
||||||
|
action="store_true",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.infile == "-":
|
if args.infile == "-":
|
||||||
@ -26,6 +34,9 @@ def main() -> None:
|
|||||||
packet = myfile.read()
|
packet = myfile.read()
|
||||||
myfile.close()
|
myfile.close()
|
||||||
|
|
||||||
|
if args.compressed:
|
||||||
|
packet = Lz77().decompress(packet)
|
||||||
|
|
||||||
benc = BinaryEncoding()
|
benc = BinaryEncoding()
|
||||||
filexml = benc.decode(packet)
|
filexml = benc.decode(packet)
|
||||||
print(filexml)
|
print(filexml)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user