Prepare the content schema for editing. Args: content_schema (dict): The content schema. Returns: dict: The old data extracted from the schema.
(self, content_schema: dict)
| 355 | return edited_slide |
| 356 | |
| 357 | def _prepare_schema(self, content_schema: dict): |
| 358 | """ |
| 359 | Prepare the content schema for editing. |
| 360 | |
| 361 | Args: |
| 362 | content_schema (dict): The content schema. |
| 363 | |
| 364 | Returns: |
| 365 | dict: The old data extracted from the schema. |
| 366 | """ |
| 367 | old_data = {} |
| 368 | for el_name, el_info in content_schema.items(): |
| 369 | if el_info["type"] == "text": |
| 370 | if not isinstance(el_info["data"], list): |
| 371 | el_info["data"] = [el_info["data"]] |
| 372 | if len(el_info["data"]) > 1: |
| 373 | charater_counts = [len(i) for i in el_info["data"]] |
| 374 | content_schema[el_name]["suggestedCharacters"] = ( |
| 375 | str(min(charater_counts)) + "-" + str(max(charater_counts)) |
| 376 | ) |
| 377 | else: |
| 378 | content_schema[el_name]["suggestedCharacters"] = "<" + str( |
| 379 | len(el_info["data"][0]) |
| 380 | ) |
| 381 | old_data[el_name] = el_info.pop("data") |
| 382 | content_schema[el_name]["default_quantity"] = 1 |
| 383 | if isinstance(old_data[el_name], list): |
| 384 | content_schema[el_name]["default_quantity"] = len(old_data[el_name]) |
| 385 | assert len(old_data) > 0, "No old data generated" |
| 386 | return old_data |
| 387 | |
| 388 | def _generate_commands( |
| 389 | self, editor_output: dict, content_schema: dict, old_data: dict, retry: int = 0 |