-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_generation.py
More file actions
280 lines (260 loc) · 9.31 KB
/
Copy pathexample_generation.py
File metadata and controls
280 lines (260 loc) · 9.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
import os
from pathlib import Path
from datetime import datetime, timedelta
from concurrent.futures import ThreadPoolExecutor
from parse_ical import parse_calendar_events
from calendar_image import save_calendar_image
from weather import geocode_location
def generate_example_calendar(location: str = None):
"""
Generate an example calendar file for testing with current week's dates
"""
# Get coordinates for location if provided
latitude, longitude = None, None
if location:
coords = geocode_location(location)
if coords:
latitude, longitude = coords
print(
f"Generating examples for location: {location} ({latitude:.4f}, {longitude:.4f})"
)
else:
print(
f"Could not find location '{location}', using default (Fort Collins, CO)"
)
else:
print("Generating examples for default location: Fort Collins, CO")
# Create synthetic example.ics with current week's dates
create_synthetic_example_ics()
events = parse_calendar_events("data/example.ics")
# no need to commit example data we can generate
os.remove("data/example.ics")
save_calendar_image(
events,
"example-calendars/floyd-steinberg-calendar.png",
dithering="floyd",
latitude=latitude,
longitude=longitude,
)
save_calendar_image(
events,
"example-calendars/atkinson-calendar.png",
dithering="atkinson",
latitude=latitude,
longitude=longitude,
)
def generate_day_calendar(days):
save_calendar_image(
events,
f"example-calendars/day-{days}-calendar.png",
current_weekday=days,
dithering="atkinson",
latitude=latitude,
longitude=longitude,
)
with ThreadPoolExecutor() as executor:
executor.map(generate_day_calendar, range(6))
def create_synthetic_example_ics():
"""
Create a synthetic example.ics file with current week's dates
"""
# Get current date and calculate the start of the current week (Monday)
today = datetime.now()
days_since_monday = today.weekday()
week_start = today - timedelta(days=days_since_monday)
# Sample events for each day of the week
sample_events = [
[
{
"time": "08:00",
"duration": 60,
"summary": "Team Standup Meeting",
"description": "Daily team synchronization and progress updates",
"location": "Conference Room A",
},
{
"time": "13:00",
"duration": 90,
"summary": "Client Presentation",
"description": "Quarterly business review with key stakeholders",
"location": "Board Room",
},
{
"time": "16:00",
"duration": 60,
"summary": "Project Planning Session",
"description": "Planning for upcoming product launch initiatives",
"location": "Meeting Room B",
},
],
[
{
"time": "09:00",
"duration": 90,
"summary": "Budget Review Meeting",
"description": "Monthly financial review and budget allocation",
"location": "Finance Conference Room",
},
{
"time": "11:00",
"duration": 60,
"summary": "Marketing Strategy Discussion",
"description": "Q3 marketing campaign planning and strategy alignment",
"location": "Marketing Office",
},
{
"time": "14:00",
"duration": 90,
"summary": "Technical Architecture Review",
"description": "System design review and technical documentation",
"location": "Tech Lab",
},
],
[
{
"time": "08:00",
"duration": 60,
"summary": "Department All-Hands",
"description": "Weekly department updates and announcements",
"location": "Main Auditorium",
},
{
"time": "11:30",
"duration": 90,
"summary": "Vendor Negotiation Call",
"description": "Contract terms discussion with software vendor",
"location": "Phone Conference",
},
{
"time": "15:00",
"duration": 90,
"summary": "User Experience Workshop",
"description": "Design thinking session for new user interface",
"location": "Design Studio",
},
],
[
{
"time": "08:30",
"duration": 90,
"summary": "Quality Assurance Review",
"description": "Testing protocols and quality standards assessment",
"location": "QA Lab",
},
{
"time": "12:00",
"duration": 90,
"summary": "Customer Feedback Session",
"description": "Review of customer surveys and feedback analysis",
"location": "Customer Success Office",
},
{
"time": "14:30",
"duration": 90,
"summary": "Security Audit Meeting",
"description": "IT security review and compliance discussion",
"location": "IT Security Room",
},
],
[
{
"time": "09:00",
"duration": 90,
"summary": "Product Development Sync",
"description": "Feature prioritization and development roadmap",
"location": "Product Office",
},
{
"time": "13:30",
"duration": 90,
"summary": "HR Policy Training",
"description": "Updated workplace policies and procedures training",
"location": "Training Room C",
},
{
"time": "16:00",
"duration": 60,
"summary": "Weekly Retrospective",
"description": "Team reflection on achievements and improvements",
"location": "Collaboration Space",
},
],
[
{
"time": "08:00",
"duration": 90,
"summary": "Sales Pipeline Review",
"description": "Weekly sales forecast and opportunity analysis",
"location": "Sales War Room",
},
{
"time": "11:00",
"duration": 90,
"summary": "Partnership Strategy Meeting",
"description": "Strategic alliance discussions and partnership planning",
"location": "Executive Conference Room",
},
{
"time": "14:30",
"duration": 90,
"summary": "Innovation Brainstorm",
"description": "Creative session for new product ideas and features",
"location": "Innovation Lab",
},
],
[
{
"time": "09:30",
"duration": 90,
"summary": "Operational Excellence Review",
"description": "Process improvement and operational efficiency analysis",
"location": "Operations Center",
},
{
"time": "13:00",
"duration": 90,
"summary": "Technology Roadmap Planning",
"description": "Future technology stack and infrastructure planning",
"location": "Tech Strategy Room",
},
{
"time": "15:00",
"duration": 90,
"summary": "Week Wrap-up Meeting",
"description": "Weekly achievements review and next week planning",
"location": "Team Meeting Room",
},
],
]
# Create the iCal content
ical_content = """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example Corp//Example Calendar//EN
CALSCALE:GREGORIAN
METHOD:PUBLISH
"""
# Generate events for the current week
for day_offset in range(7):
current_date = week_start + timedelta(days=day_offset)
date_str = current_date.strftime("%Y%m%d")
for i, event in enumerate(sample_events[day_offset]):
start_time = datetime.strptime(
f"{date_str}T{event['time'].replace(':', '')}", "%Y%m%dT%H%M"
)
end_time = start_time + timedelta(minutes=event["duration"])
ical_content += f"""BEGIN:VEVENT
UID:{date_str}-event{i + 1}@example.com
DTSTART:{start_time.strftime("%Y%m%dT%H%M%S")}
DTEND:{end_time.strftime("%Y%m%dT%H%M%S")}
SUMMARY:{event["summary"]}
DESCRIPTION:{event["description"]}
LOCATION:{event["location"]}
STATUS:CONFIRMED
END:VEVENT
"""
ical_content += "END:VCALENDAR"
# Ensure data directory exists
Path("data").mkdir(parents=True, exist_ok=True)
# Write the synthetic iCal file
with open("data/example.ics", "w") as f:
f.write(ical_content)