MCPcopy Index your code
hub / github.com/couchbase/couchbase-python-client / decode_value

Method decode_value

couchbase/transcoder.py:169–187  ·  view source on GitHub ↗
(self,
                     value,  # type: bytes
                     flags  # type: int
                     )

Source from the content-addressed store, hash-verified

167 raise ValueFormatException("Only binary and string data supported by RawJSONTranscoder")
168
169 def decode_value(self,
170 value, # type: bytes
171 flags # type: int
172 ) -> Union[str, bytes]:
173
174 format = get_decode_format(flags)
175
176 if format == FMT_BYTES:
177 raise ValueFormatException("Binary format type not supported by RawJSONTranscoder")
178 elif format == FMT_UTF8:
179 raise ValueFormatException("String format type not supported by RawJSONTranscoder")
180 elif format == FMT_JSON:
181 if isinstance(value, str):
182 value = value.decode('utf-8')
183 elif isinstance(value, bytearray):
184 value = bytes(value)
185 return value
186 else:
187 raise ValueFormatException(f"Unrecognized format provided: {format}")
188
189
190class RawStringTranscoder(Transcoder):

Callers

nothing calls this directly

Calls 2

get_decode_formatFunction · 0.85

Tested by

no test coverage detected