Debian Codegraph @

benchmark/issue42.py

raw symbols SCIP
1 # py3
2 #
3 # This is the benchmark for rrule speed
4 # see https://github.com/niccokunzmann/python-recurring-ical-events/issues/42
5 #
6
7 import sys
8 from pathlib import Path
9
10 import icalendar
11
12 import recurring_ical_events
13
14 HERE = Path(__file__).parent or Path()
15 sys.path.append(HERE.parent)
16
17
18 # read utf
19 text = []
20 with Path(HERE / "issue42.ics").open("rb") as fobj:
21 text += fobj.readlines()
22 text_utf = [i.decode("utf-8") for i in text]
23
24 ical_string = "".join(text_utf)
25
26
27 calendar = icalendar.Calendar.from_ical(ical_string)
28
29 rec_calendar = recurring_ical_events.of(calendar)
30
31 for day in range(1, 29):
32 print("day", day) # noqa: T201
33 start_date = (2011, 11, day)
34 events = rec_calendar.at(start_date)