Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/icalendar/parser/ical/calendar.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

14 statements  

1"""Special parsing for calendar components.""" 

2 

3from .component import ComponentIcalParser 

4 

5 

6class CalendarIcalParser(ComponentIcalParser): 

7 """A parser for calendar components.""" 

8 

9 def prepare_components(self) -> None: 

10 """Prepare the parsed components. 

11 

12 This handles timezone forward references. 

13 """ 

14 all_timezones_so_far = True 

15 for comp in self._components: 

16 for component in comp.subcomponents: 

17 if component.name == "VTIMEZONE": 

18 if not all_timezones_so_far: 

19 # If a preceding component refers to a VTIMEZONE 

20 # defined later in the source string (forward 

21 # references are allowed by RFC 5545), then the 

22 # earlier component may have the wrong timezone 

23 # attached. 

24 # However, during computation of comps, all VTIMEZONEs 

25 # observed do end up in the timezone cache. So simply 

26 # re-running from_ical will rely on the cache for those 

27 # forward references to produce the correct result. 

28 # See test_create_america_new_york_forward_reference. 

29 self.initialize_parsing() 

30 self.parse_content_lines() 

31 return 

32 else: 

33 all_timezones_so_far = False 

34 

35 

36__all__ = ["CalendarIcalParser"]