示例#1
0
def json2proto_bin(vcd_json_file_in, vcd_proto_file_out):
    vcd_message = proto.VCD()
    with open(vcd_json_file_in, "r") as f:
        Parse(f.read(), vcd_message)

    with open(vcd_proto_file_out, "wb") as f:
        f.write(vcd_message.SerializeToString())
示例#2
0
def proto_bin2json(vcd_proto_file_in, vcd_json_file_out):
    vcd_message = proto.VCD()

    with open(vcd_proto_file_in, "rb") as f:
        vcd_message.ParseFromString(f.read())

    with open(vcd_json_file_out, "w") as f:
        f.write(
            MessageToJson(vcd_message,
                          preserving_proto_field_name=True,
                          indent=4))