summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJared Junyoung Lim <jylim9823@gmail.com>2022-12-14 14:42:56 -0800
committerGitHub <noreply@github.com>2022-12-14 14:42:56 -0800
commit40aa964057746c0e8f913228de95973a46ee3c0e (patch)
tree7847f1e267f750209365048a5ed3596588be91da /python
parente1a2f688e0d12385fd977cb45d58453d88d7c0e2 (diff)
downloadflatbuffers-40aa964057746c0e8f913228de95973a46ee3c0e.tar.gz
flatbuffers-40aa964057746c0e8f913228de95973a46ee3c0e.tar.bz2
flatbuffers-40aa964057746c0e8f913228de95973a46ee3c0e.zip
Add Ref.AsStringBytes to flatbuffers.flexbuffers Python API (#7713)
* Add Ref.AsStringBytes to flatbuffers.flexbuffers Python API * Append Bytes to AsStringBytes return value Co-authored-by: Jared Junyoung Lim <jaredlim@google.com>
Diffstat (limited to 'python')
-rw-r--r--python/flatbuffers/flexbuffers.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/python/flatbuffers/flexbuffers.py b/python/flatbuffers/flexbuffers.py
index da10668a..aaa02fda 100644
--- a/python/flatbuffers/flexbuffers.py
+++ b/python/flatbuffers/flexbuffers.py
@@ -728,6 +728,15 @@ class Ref:
return self._type is Type.STRING
@property
+ def AsStringBytes(self):
+ if self.IsString:
+ return String(self._Indirect(), self._byte_width).Bytes
+ elif self.IsKey:
+ return self.AsKeyBytes
+ else:
+ raise self._ConvertError(Type.STRING)
+
+ @property
def AsString(self):
if self.IsString:
return str(String(self._Indirect(), self._byte_width))