MCPcopy Create free account
hub / github.com/apple/coremltools / MergeFromString

Method MergeFromString

deps/protobuf/python/google/protobuf/message.py:160–191  ·  view source on GitHub ↗

Merges serialized protocol buffer data into this message. When we find a field in `serialized` that is already present in this message: - If it's a "repeated" field, we append to the end of our list. - Else, if it's a scalar, we overwrite our field. - Else, (it's a nonrep

(self, serialized)

Source from the content-addressed store, hash-verified

158 # MergeFromString().
159
160 def MergeFromString(self, serialized):
161 """Merges serialized protocol buffer data into this message.
162
163 When we find a field in `serialized` that is already present
164 in this message:
165
166 - If it's a "repeated" field, we append to the end of our list.
167 - Else, if it's a scalar, we overwrite our field.
168 - Else, (it's a nonrepeated composite), we recursively merge
169 into the existing composite.
170
171 Args:
172 serialized (bytes): Any object that allows us to call
173 ``memoryview(serialized)`` to access a string of bytes using the
174 buffer interface.
175
176 Returns:
177 int: The number of bytes read from `serialized`.
178 For non-group messages, this will always be `len(serialized)`,
179 but for messages which are actually groups, this will
180 generally be less than `len(serialized)`, since we must
181 stop when we reach an ``END_GROUP`` tag. Note that if
182 we *do* stop because of an ``END_GROUP`` tag, the number
183 of bytes returned does not include the bytes
184 for the ``END_GROUP`` tag information.
185
186 Raises:
187 DecodeError: if the input cannot be parsed.
188 """
189 # TODO(robinson): Document handling of unknown fields.
190 # TODO(robinson): When we switch to a helper, this will return None.
191 raise NotImplementedError
192
193 def ParseFromString(self, serialized):
194 """Parse serialized protocol buffer data into this message.

Calls

no outgoing calls