| OLD | NEW |
| 1 # Protocol Buffers - Google's data interchange format | 1 # Protocol Buffers - Google's data interchange format |
| 2 # Copyright 2008 Google Inc. All rights reserved. | 2 # Copyright 2008 Google Inc. All rights reserved. |
| 3 # https://developers.google.com/protocol-buffers/ | 3 # https://developers.google.com/protocol-buffers/ |
| 4 # | 4 # |
| 5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
| 6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
| 7 # met: | 7 # met: |
| 8 # | 8 # |
| 9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
| 10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 # What do we do with fields that share names with Python keywords | 218 # What do we do with fields that share names with Python keywords |
| 219 # like 'lambda' and 'yield'? | 219 # like 'lambda' and 'yield'? |
| 220 # | 220 # |
| 221 # nnorwitz says: | 221 # nnorwitz says: |
| 222 # """ | 222 # """ |
| 223 # Typically (in python), an underscore is appended to names that are | 223 # Typically (in python), an underscore is appended to names that are |
| 224 # keywords. So they would become lambda_ or yield_. | 224 # keywords. So they would become lambda_ or yield_. |
| 225 # """ | 225 # """ |
| 226 def ListFields(self): | 226 def ListFields(self): |
| 227 """Returns a list of (FieldDescriptor, value) tuples for all | 227 """Returns a list of (FieldDescriptor, value) tuples for all |
| 228 fields in the message which are not empty. A singular field is non-empty | 228 fields in the message which are not empty. A message field is |
| 229 if HasField() would return true, and a repeated field is non-empty if | 229 non-empty if HasField() would return true. A singular primitive field |
| 230 it contains at least one element. The fields are ordered by field | 230 is non-empty if HasField() would return true in proto2 or it is non zero |
| 231 number""" | 231 in proto3. A repeated field is non-empty if it contains at least one |
| 232 element. The fields are ordered by field number""" |
| 232 raise NotImplementedError | 233 raise NotImplementedError |
| 233 | 234 |
| 234 def HasField(self, field_name): | 235 def HasField(self, field_name): |
| 235 """Checks if a certain field is set for the message, or if any field inside | 236 """Checks if a certain field is set for the message, or if any field inside |
| 236 a oneof group is set. Note that if the field_name is not defined in the | 237 a oneof group is set. Note that if the field_name is not defined in the |
| 237 message descriptor, ValueError will be raised.""" | 238 message descriptor, ValueError will be raised.""" |
| 238 raise NotImplementedError | 239 raise NotImplementedError |
| 239 | 240 |
| 240 def ClearField(self, field_name): | 241 def ClearField(self, field_name): |
| 241 """Clears the contents of a given field, or the field set inside a oneof | 242 """Clears the contents of a given field, or the field set inside a oneof |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 raise NotImplementedError | 287 raise NotImplementedError |
| 287 | 288 |
| 288 def __getstate__(self): | 289 def __getstate__(self): |
| 289 """Support the pickle protocol.""" | 290 """Support the pickle protocol.""" |
| 290 return dict(serialized=self.SerializePartialToString()) | 291 return dict(serialized=self.SerializePartialToString()) |
| 291 | 292 |
| 292 def __setstate__(self, state): | 293 def __setstate__(self, state): |
| 293 """Support the pickle protocol.""" | 294 """Support the pickle protocol.""" |
| 294 self.__init__() | 295 self.__init__() |
| 295 self.ParseFromString(state['serialized']) | 296 self.ParseFromString(state['serialized']) |
| OLD | NEW |