(argv)
| 18 | |
| 19 | |
| 20 | def main(argv): |
| 21 | parser = argparse.ArgumentParser(description=( |
| 22 | "Converts from .pdl to .json by invoking the pdl Python module.")) |
| 23 | parser.add_argument('--map_binary_to_string', type=bool, |
| 24 | help=('If set, binary in the .pdl is mapped to a ' |
| 25 | 'string in .json. Client code will have to ' |
| 26 | 'base64 decode the string to get the payload.')) |
| 27 | parser.add_argument("pdl_file", help="The .pdl input file to parse.") |
| 28 | parser.add_argument("json_file", help="The .json output file write.") |
| 29 | args = parser.parse_args(argv) |
| 30 | file_name = os.path.normpath(args.pdl_file) |
| 31 | input_file = open(file_name, "r") |
| 32 | pdl_string = input_file.read() |
| 33 | protocol = pdl.loads(pdl_string, file_name, args.map_binary_to_string) |
| 34 | input_file.close() |
| 35 | output_file = open_to_write(os.path.normpath(args.json_file)) |
| 36 | json.dump(protocol, output_file, indent=4, separators=(',', ': ')) |
| 37 | output_file.close() |
| 38 | |
| 39 | |
| 40 | if __name__ == '__main__': |
no test coverage detected
searching dependent graphs…