diff options
author | Jared Junyoung Lim <jylim9823@gmail.com> | 2022-12-14 14:42:56 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-14 14:42:56 -0800 |
commit | 40aa964057746c0e8f913228de95973a46ee3c0e (patch) | |
tree | 7847f1e267f750209365048a5ed3596588be91da /python | |
parent | e1a2f688e0d12385fd977cb45d58453d88d7c0e2 (diff) | |
download | flatbuffers-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.py | 9 |
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)) |