Reads a protobuffer with the given proto class. Inputs: cls: a protobuffer class. s: a string of either binary or text protobuffer content. Outputs: proto: the protobuffer of cls Throws: google.protobuf.message.DecodeError: if we cannot decode the message.
(cls, s)
| 195 | |
| 196 | |
| 197 | def TryReadProtoWithClass(cls, s): |
| 198 | """Reads a protobuffer with the given proto class. |
| 199 | |
| 200 | Inputs: |
| 201 | cls: a protobuffer class. |
| 202 | s: a string of either binary or text protobuffer content. |
| 203 | |
| 204 | Outputs: |
| 205 | proto: the protobuffer of cls |
| 206 | |
| 207 | Throws: |
| 208 | google.protobuf.message.DecodeError: if we cannot decode the message. |
| 209 | """ |
| 210 | obj = cls() |
| 211 | try: |
| 212 | text_format.Parse(s, obj) |
| 213 | return obj |
| 214 | except (text_format.ParseError, UnicodeDecodeError): |
| 215 | obj.ParseFromString(s) |
| 216 | return obj |
| 217 | |
| 218 | |
| 219 | def GetContentFromProto(obj, function_map): |
no outgoing calls
no test coverage detected
searching dependent graphs…