Skip to content

Commit 95b1869

Browse files
committed
refactor: replace Pydantic models with dataclasses for PlaceholderInfo, LayoutInfo, and MasterInfo
1 parent 8bfb647 commit 95b1869

File tree

1 file changed

+19
-24
lines changed

1 file changed

+19
-24
lines changed

src/tppt/tool/ppt2template.py

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,43 @@
33
import argparse
44
import os
55
import re
6+
from dataclasses import dataclass
67
from pathlib import Path
78
from typing import Any, Dict, List, Optional, Set
89

910
from pptx import Presentation as PptxPresentation
10-
from pydantic import BaseModel, Field
1111

1212
import tppt
1313

1414

15-
class PlaceholderInfo(BaseModel):
15+
@dataclass
16+
class PlaceholderInfo:
1617
"""Information about a placeholder."""
1718

18-
name: str = Field(description="Name of the placeholder")
19-
type: int = Field(description="Type ID of the placeholder")
20-
field_name: Optional[str] = Field(default=None, description="Python field name")
21-
field_type: Optional[str] = Field(
22-
default=None, description="Python field type definition"
23-
)
24-
required: bool = Field(default=False, description="Whether the field is required")
25-
idx: Optional[int] = Field(default=None, description="Index within the layout")
19+
name: str
20+
type: int
21+
field_name: Optional[str] = None
22+
field_type: Optional[str] = None
23+
required: bool = False
24+
idx: Optional[int] = None
2625

2726

28-
class LayoutInfo(BaseModel):
27+
@dataclass
28+
class LayoutInfo:
2929
"""Information about a slide layout."""
3030

31-
name: str = Field(description="Name of the layout")
32-
placeholders: List[PlaceholderInfo] = Field(
33-
description="List of placeholders in the layout"
34-
)
35-
class_name: Optional[str] = Field(
36-
default=None, description="Python class name for this layout"
37-
)
31+
name: str
32+
placeholders: List[PlaceholderInfo]
33+
class_name: Optional[str] = None
3834

3935

40-
class MasterInfo(BaseModel):
36+
@dataclass
37+
class MasterInfo:
4138
"""Information about a slide master."""
4239

43-
name: str = Field(description="Name of the slide master")
44-
layouts: List[LayoutInfo] = Field(description="Layouts in this master")
45-
class_name: Optional[str] = Field(
46-
default=None, description="Python class name for this master"
47-
)
40+
name: str
41+
layouts: List[LayoutInfo]
42+
class_name: Optional[str] = None
4843

4944

5045
def extract_master_info(tree: Dict[str, Any]) -> MasterInfo:

0 commit comments

Comments
 (0)