MCPcopy Create free account
hub / github.com/ScrapeGraphAI/toonify / _encode_array_with_key

Function _encode_array_with_key

toon/encoder.py:193–210  ·  view source on GitHub ↗

Encode an array with its key prefix for object context.

(key: str, arr: list, level: int, opts: EncoderOptions)

Source from the content-addressed store, hash-verified

191
192
193def _encode_array_with_key(key: str, arr: list, level: int, opts: EncoderOptions) -> str:
194 """Encode an array with its key prefix for object context."""
195 if not arr:
196 return '[]'
197
198 indent = get_indent(level, opts.indent)
199
200 # Check if it's a uniform array of objects (tabular format)
201 fields = is_uniform_array_of_objects(arr)
202 if fields:
203 return _encode_tabular_array(arr, fields, level, opts, key=key)
204
205 # Check if all elements are primitives (inline format)
206 if all(is_primitive(item) for item in arr):
207 return _encode_primitive_array(arr, opts)
208
209 # Mixed array (list format)
210 return _encode_list_array(arr, level, opts, key=key)
211
212
213

Callers 1

_encode_objectFunction · 0.85

Calls 6

get_indentFunction · 0.85
_encode_tabular_arrayFunction · 0.85
is_primitiveFunction · 0.85
_encode_primitive_arrayFunction · 0.85
_encode_list_arrayFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…