MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / main

Function main

common/devtools/convert_protocol_to_json.py:14–35  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

12
13
14def main(argv):
15 parser = argparse.ArgumentParser(description=("Converts from .pdl to .json by invoking the pdl Python module."))
16 parser.add_argument(
17 "--map_binary_to_string",
18 type=bool,
19 help=(
20 "If set, binary in the .pdl is mapped to a "
21 "string in .json. Client code will have to "
22 "base64 decode the string to get the payload."
23 ),
24 )
25 parser.add_argument("pdl_file", help="The .pdl input file to parse.")
26 parser.add_argument("json_file", help="The .json output file write.")
27 args = parser.parse_args(argv)
28 file_name = os.path.normpath(args.pdl_file)
29 with open(file_name) as input_file:
30 pdl_string = input_file.read()
31
32 protocol = pdl.loads(pdl_string, file_name, args.map_binary_to_string)
33
34 with open(os.path.normpath(args.json_file), "w") as output_file:
35 json.dump(protocol, output_file, indent=4, separators=(",", ": "))
36
37
38if __name__ == "__main__":

Callers 1

Calls 2

readMethod · 0.65
add_argumentMethod · 0.45

Tested by

no test coverage detected