Convert to dictionary for JSON serialization.
(self)
| 690 | ) |
| 691 | |
| 692 | def to_dict(self) -> ShapeDict: |
| 693 | """Convert to dictionary for JSON serialization.""" |
| 694 | result: ShapeDict = { |
| 695 | "left": self.left, |
| 696 | "top": self.top, |
| 697 | "width": self.width, |
| 698 | "height": self.height, |
| 699 | } |
| 700 | |
| 701 | # Add optional fields if present |
| 702 | if self.placeholder_type: |
| 703 | result["placeholder_type"] = self.placeholder_type |
| 704 | |
| 705 | if self.default_font_size: |
| 706 | result["default_font_size"] = self.default_font_size |
| 707 | |
| 708 | # Add overflow information only if there is overflow |
| 709 | overflow_data = {} |
| 710 | |
| 711 | # Add frame overflow if present |
| 712 | if self.frame_overflow_bottom is not None: |
| 713 | overflow_data["frame"] = {"overflow_bottom": self.frame_overflow_bottom} |
| 714 | |
| 715 | # Add slide overflow if present |
| 716 | slide_overflow = {} |
| 717 | if self.slide_overflow_right is not None: |
| 718 | slide_overflow["overflow_right"] = self.slide_overflow_right |
| 719 | if self.slide_overflow_bottom is not None: |
| 720 | slide_overflow["overflow_bottom"] = self.slide_overflow_bottom |
| 721 | if slide_overflow: |
| 722 | overflow_data["slide"] = slide_overflow |
| 723 | |
| 724 | # Only add overflow field if there is overflow |
| 725 | if overflow_data: |
| 726 | result["overflow"] = overflow_data |
| 727 | |
| 728 | # Add overlap field if there are overlapping shapes |
| 729 | if self.overlapping_shapes: |
| 730 | result["overlap"] = {"overlapping_shapes": self.overlapping_shapes} |
| 731 | |
| 732 | # Add warnings field if there are warnings |
| 733 | if self.warnings: |
| 734 | result["warnings"] = self.warnings |
| 735 | |
| 736 | # Add paragraphs after placeholder_type |
| 737 | result["paragraphs"] = [para.to_dict() for para in self.paragraphs] |
| 738 | |
| 739 | return result |
| 740 | |
| 741 | |
| 742 | def is_valid_shape(shape: BaseShape) -> bool: |
no outgoing calls
no test coverage detected