MCPcopy Create free account
hub / github.com/cdgriffith/Box / _to_native_tuple

Function _to_native_tuple

box/box.py:174–190  ·  view source on GitHub ↗

Convert a tuple's Box/BoxList members back to native types. ``frozen_box`` stores lists as tuples of Boxes, so ``to_dict`` needs to turn those nested Boxes back into plain dicts to remain serializable.

(iterable)

Source from the content-addressed store, hash-verified

172
173
174def _to_native_tuple(iterable):
175 """Convert a tuple's Box/BoxList members back to native types.
176
177 ``frozen_box`` stores lists as tuples of Boxes, so ``to_dict`` needs to
178 turn those nested Boxes back into plain dicts to remain serializable.
179 """
180 out_list = []
181 for i in iterable:
182 if isinstance(i, Box):
183 out_list.append(i.to_dict())
184 elif isinstance(i, box.BoxList):
185 out_list.append(i.to_list())
186 elif isinstance(i, tuple):
187 out_list.append(_to_native_tuple(i))
188 else:
189 out_list.append(i)
190 return tuple(out_list)
191
192
193def _parse_box_dots(bx, item):

Callers 1

to_dictMethod · 0.85

Calls 3

appendMethod · 0.80
to_dictMethod · 0.80
to_listMethod · 0.80

Tested by

no test coverage detected