summaryrefslogtreecommitdiff
path: root/tools/inspector_protocol/convert_protocol_to_json.py
diff options
context:
space:
mode:
authorPavel Feldman <pfeldman@chromium.org>2019-02-25 12:43:13 -0800
committerRefael Ackermann <refack@gmail.com>2019-03-04 11:44:49 -0500
commitd775d74698e1b321580b1560fbcee7943750aedc (patch)
treee603e6285066de1e55a25397deef5edd41959887 /tools/inspector_protocol/convert_protocol_to_json.py
parentb2abda9ba0b7b8bfbbf14e990ea86434f3f20de3 (diff)
downloadandroid-node-v8-d775d74698e1b321580b1560fbcee7943750aedc.tar.gz
android-node-v8-d775d74698e1b321580b1560fbcee7943750aedc.tar.bz2
android-node-v8-d775d74698e1b321580b1560fbcee7943750aedc.zip
tools: roll inspector_protocol to f67ec5
Fixes: https://github.com/nodejs/node/issues/25808 PR-URL: https://github.com/nodejs/node/pull/26303 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'tools/inspector_protocol/convert_protocol_to_json.py')
-rwxr-xr-xtools/inspector_protocol/convert_protocol_to_json.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/inspector_protocol/convert_protocol_to_json.py b/tools/inspector_protocol/convert_protocol_to_json.py
new file mode 100755
index 0000000000..96048f793d
--- /dev/null
+++ b/tools/inspector_protocol/convert_protocol_to_json.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import argparse
+import collections
+import json
+import os.path
+import re
+import sys
+
+import pdl
+
+def main(argv):
+ parser = argparse.ArgumentParser(description=(
+ "Converts from .pdl to .json by invoking the pdl Python module."))
+ parser.add_argument('--map_binary_to_string', type=bool,
+ help=('If set, binary in the .pdl is mapped to a '
+ 'string in .json. Client code will have to '
+ 'base64 decode the string to get the payload.'))
+ parser.add_argument("pdl_file", help="The .pdl input file to parse.")
+ parser.add_argument("json_file", help="The .json output file write.")
+ args = parser.parse_args(argv)
+ file_name = os.path.normpath(args.pdl_file)
+ input_file = open(file_name, "r")
+ pdl_string = input_file.read()
+ protocol = pdl.loads(pdl_string, file_name, args.map_binary_to_string)
+ input_file.close()
+
+ output_file = open(os.path.normpath(args.json_file), 'wb')
+ json.dump(protocol, output_file, indent=4, separators=(',', ': '))
+ output_file.close()
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))