diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/tools/inspect_dumpfile.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/tools/inspect_dumpfile.py b/test/tools/inspect_dumpfile.py new file mode 100644 index 00000000..8ba42c2a --- /dev/null +++ b/test/tools/inspect_dumpfile.py @@ -0,0 +1,32 @@ +from pprint import pprint + +import click + +from libmproxy import tnetstring + + +def read_tnetstring(input): + # tnetstring throw a ValueError on EOF, which is hard to catch + # because they raise ValueErrors for a couple of other reasons. + # Check for EOF to avoid this. + if not input.read(1): + return None + else: + input.seek(-1, 1) + return tnetstring.load(input) + +@click.command() +@click.argument("input", type=click.File('rb')) +def inspect(input): + """ + pretty-print a dumpfile + """ + while True: + data = read_tnetstring(input) + if not data: + break + pprint(data) + + +if __name__ == "__main__": + inspect() |