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

Function _generate_array_structure

toon/structure_generator.py:103–132  ·  view source on GitHub ↗

Generate structure template for an array.

(
    schema: List[Any], 
    level: int, 
    delimiter: str, 
    indent_size: int,
    key: Optional[str] = None
)

Source from the content-addressed store, hash-verified

101
102
103def _generate_array_structure(
104 schema: List[Any],
105 level: int,
106 delimiter: str,
107 indent_size: int,
108 key: Optional[str] = None
109) -> str:
110 """Generate structure template for an array."""
111 if not schema:
112 return "[]"
113
114 indent = get_indent(level, indent_size)
115
116 # Check if it's an array of objects (tabular format)
117 if isinstance(schema[0], dict):
118 return _generate_tabular_array_structure(
119 schema[0], level, delimiter, indent_size, key
120 )
121 elif isinstance(schema[0], str):
122 # Array of primitive descriptions
123 if key:
124 return f'{indent}{key}{COLON} [<{schema[0]}>,...]'
125 else:
126 return f'[<{schema[0]}>,...]'
127 else:
128 # Generic array
129 if key:
130 return f'{indent}{key}{COLON} [...]'
131 else:
132 return '[...]'
133
134
135def _generate_tabular_array_structure(

Callers 2

generate_structureFunction · 0.85

Calls 2

get_indentFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…