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

Function _generate_tabular_array_structure

toon/structure_generator.py:135–175  ·  view source on GitHub ↗

Generate structure template for a tabular array.

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

Source from the content-addressed store, hash-verified

133
134
135def _generate_tabular_array_structure(
136 field_schema: Dict[str, Any],
137 level: int,
138 delimiter: str,
139 indent_size: int,
140 key: Optional[str] = None
141) -> str:
142 """Generate structure template for a tabular array."""
143 indent = get_indent(level, indent_size)
144
145 # Get field names
146 fields = list(field_schema.keys())
147
148 # Delimiter indicator for non-comma delimiters
149 delimiter_indicator = ''
150 if delimiter == '\t':
151 delimiter_indicator = '\t'
152 elif delimiter == '|':
153 delimiter_indicator = '|'
154
155 # Header: key[N]{field1,field2,...}: or [N]{field1,field2,...}:
156 if key:
157 header = f'{indent}{key}[N{delimiter_indicator}]{LEFT_BRACE}{COMMA.join(fields)}{RIGHT_BRACE}{COLON}'
158 else:
159 header = f'[N{delimiter_indicator}]{LEFT_BRACE}{COMMA.join(fields)}{RIGHT_BRACE}{COLON}'
160
161 lines = [header]
162
163 # Create a sample row with descriptions
164 row_parts = []
165 for field, description in field_schema.items():
166 if isinstance(description, str):
167 row_parts.append(f'<{description}>')
168 else:
169 row_parts.append('<value>')
170
171 row = delimiter.join(row_parts)
172 lines.append(f'{indent} {row}')
173 lines.append(f'{indent} ...')
174
175 return NEWLINE.join(lines)
176
177
178def generate_structure_from_pydantic(

Callers 1

Calls 1

get_indentFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…