aboutsummaryrefslogtreecommitdiffstats
path: root/test/helper_tools/inspect_dumpfile.py
diff options
context:
space:
mode:
authorThomas Kriechbaumer <Kriechi@users.noreply.github.com>2017-02-15 00:24:05 +0100
committerGitHub <noreply@github.com>2017-02-15 00:24:05 +0100
commitbb2fa6dc7d871d703c6759926521d8c16aae80f1 (patch)
tree63439432d40bd5f0740000b71da0dc6df6053e3c /test/helper_tools/inspect_dumpfile.py
parenta3436897ad8c504c08cff40bcddd7915c13a4712 (diff)
parent4d973e82959f5aecab8313b43ce1ab484f21b536 (diff)
downloadmitmproxy-bb2fa6dc7d871d703c6759926521d8c16aae80f1.tar.gz
mitmproxy-bb2fa6dc7d871d703c6759926521d8c16aae80f1.tar.bz2
mitmproxy-bb2fa6dc7d871d703c6759926521d8c16aae80f1.zip
Merge pull request #2026 from Kriechi/filename-matching
add filename-matching linter
Diffstat (limited to 'test/helper_tools/inspect_dumpfile.py')
-rw-r--r--test/helper_tools/inspect_dumpfile.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/helper_tools/inspect_dumpfile.py b/test/helper_tools/inspect_dumpfile.py
new file mode 100644
index 00000000..b2201f40
--- /dev/null
+++ b/test/helper_tools/inspect_dumpfile.py
@@ -0,0 +1,33 @@
+from pprint import pprint
+
+import click
+
+from mitmproxy 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()