google-workspace-mcp 1.1.5__py3-none-any.whl → 1.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,201 +0,0 @@
1
- """
2
- Unit conversion utilities for Google Slides API.
3
-
4
- This module provides functions to convert between different units used in Google Slides:
5
- - EMU (English Metric Units): 1 inch = 914,400 EMU, 1 point = 12,700 EMU
6
- - PT (Points): 1 inch = 72 PT
7
- - Inches
8
- """
9
-
10
- import logging
11
- from typing import Any, Dict, Union
12
-
13
- logger = logging.getLogger(__name__)
14
-
15
- # Conversion constants based on Google Slides API documentation
16
- EMU_PER_INCH = 914400
17
- EMU_PER_POINT = 12700
18
- POINTS_PER_INCH = 72
19
-
20
-
21
- def emu_to_pt(emu: Union[int, float]) -> float:
22
- """
23
- Convert EMU (English Metric Units) to Points.
24
-
25
- Args:
26
- emu: Value in EMU units
27
-
28
- Returns:
29
- Value in Points
30
- """
31
- return float(emu) / EMU_PER_POINT
32
-
33
-
34
- def pt_to_emu(points: Union[int, float]) -> int:
35
- """
36
- Convert Points to EMU (English Metric Units).
37
-
38
- Args:
39
- points: Value in Points
40
-
41
- Returns:
42
- Value in EMU units
43
- """
44
- return int(float(points) * EMU_PER_POINT)
45
-
46
-
47
- def emu_to_inches(emu: Union[int, float]) -> float:
48
- """
49
- Convert EMU (English Metric Units) to inches.
50
-
51
- Args:
52
- emu: Value in EMU units
53
-
54
- Returns:
55
- Value in inches
56
- """
57
- return float(emu) / EMU_PER_INCH
58
-
59
-
60
- def inches_to_emu(inches: Union[int, float]) -> int:
61
- """
62
- Convert inches to EMU (English Metric Units).
63
-
64
- Args:
65
- inches: Value in inches
66
-
67
- Returns:
68
- Value in EMU units
69
- """
70
- return int(float(inches) * EMU_PER_INCH)
71
-
72
-
73
- def pt_to_inches(points: Union[int, float]) -> float:
74
- """
75
- Convert Points to inches.
76
-
77
- Args:
78
- points: Value in Points
79
-
80
- Returns:
81
- Value in inches
82
- """
83
- return float(points) / POINTS_PER_INCH
84
-
85
-
86
- def inches_to_pt(inches: Union[int, float]) -> float:
87
- """
88
- Convert inches to Points.
89
-
90
- Args:
91
- inches: Value in inches
92
-
93
- Returns:
94
- Value in Points
95
- """
96
- return float(inches) * POINTS_PER_INCH
97
-
98
-
99
- def convert_template_zone_coordinates(
100
- zone_data: Dict[str, Any], target_unit: str = "PT"
101
- ) -> Dict[str, Any]:
102
- """
103
- Convert template zone coordinates from EMU to specified target unit.
104
-
105
- Args:
106
- zone_data: Dictionary containing zone information with EMU coordinates
107
- target_unit: Target unit ("PT", "EMU", or "INCHES")
108
-
109
- Returns:
110
- Dictionary with additional coordinates in target unit
111
- """
112
- if target_unit not in ["PT", "EMU", "INCHES"]:
113
- raise ValueError("target_unit must be 'PT', 'EMU', or 'INCHES'")
114
-
115
- # Create a copy to avoid modifying the original
116
- converted_zone = zone_data.copy()
117
-
118
- # Get EMU coordinates (these should always be present)
119
- x_emu = zone_data.get("x_emu", 0)
120
- y_emu = zone_data.get("y_emu", 0)
121
- width_emu = zone_data.get("width_emu", 0)
122
- height_emu = zone_data.get("height_emu", 0)
123
-
124
- if target_unit == "PT":
125
- converted_zone.update(
126
- {
127
- "x_pt": emu_to_pt(x_emu),
128
- "y_pt": emu_to_pt(y_emu),
129
- "width_pt": emu_to_pt(width_emu),
130
- "height_pt": emu_to_pt(height_emu),
131
- }
132
- )
133
- elif target_unit == "INCHES":
134
- converted_zone.update(
135
- {
136
- "x_inches": emu_to_inches(x_emu),
137
- "y_inches": emu_to_inches(y_emu),
138
- "width_inches": emu_to_inches(width_emu),
139
- "height_inches": emu_to_inches(height_emu),
140
- }
141
- )
142
- # For EMU, coordinates are already present
143
-
144
- return converted_zone
145
-
146
-
147
- def convert_template_zones(
148
- template_zones: Dict[str, Any], target_unit: str = "PT"
149
- ) -> Dict[str, Any]:
150
- """
151
- Convert all template zones coordinates to specified target unit.
152
-
153
- Args:
154
- template_zones: Dictionary containing template zones data
155
- target_unit: Target unit ("PT", "EMU", or "INCHES")
156
-
157
- Returns:
158
- Dictionary with converted template zones
159
- """
160
- if not template_zones:
161
- raise ValueError("template_zones cannot be empty")
162
-
163
- converted_zones = {}
164
-
165
- # Handle both nested structure (from extract_template_zones_only)
166
- # and flat structure (single slide zones)
167
- if "slides_analyzed" in template_zones:
168
- # Nested structure from extract_template_zones_only
169
- converted_zones = template_zones.copy()
170
- converted_zones["slides_analyzed"] = []
171
-
172
- for slide_data in template_zones["slides_analyzed"]:
173
- converted_slide = slide_data.copy()
174
- if "template_zones" in slide_data:
175
- converted_slide["template_zones"] = {}
176
- for zone_name, zone_data in slide_data["template_zones"].items():
177
- converted_slide["template_zones"][zone_name] = (
178
- convert_template_zone_coordinates(zone_data, target_unit)
179
- )
180
- converted_zones["slides_analyzed"].append(converted_slide)
181
-
182
- elif "zones" in template_zones:
183
- # Single slide structure from extract_template_zones_by_text
184
- converted_zones = template_zones.copy()
185
- converted_zones["zones"] = {}
186
-
187
- for zone_name, zone_data in template_zones["zones"].items():
188
- converted_zones["zones"][zone_name] = convert_template_zone_coordinates(
189
- zone_data, target_unit
190
- )
191
- else:
192
- # Direct zones dictionary
193
- for zone_name, zone_data in template_zones.items():
194
- converted_zones[zone_name] = convert_template_zone_coordinates(
195
- zone_data, target_unit
196
- )
197
-
198
- logger.info(
199
- f"Converted {len(template_zones)} template zones to {target_unit} coordinates"
200
- )
201
- return converted_zones