icalendar.parser.ical.lazy module#
Special parsing for calendar components.
- class icalendar.parser.ical.lazy.LazyCalendarIcalParser(data, component_factory, types_factory)[source]#
Bases:
ComponentIcalParserA parser for calendar components.
Instead of parsing the components, LazyComponents are created. Parsing can happen on demand.
A calendar may grow over time, with its subcomponents greatly increasing in number, and requiring more memory and time to fully parse. This optimization lazily parses calendar files without consuming more memory than necessary, reducing the initial time it takes to access meta data.
Initialize the parser with the raw data.
- Parameters:
data (
bytes|str|list[Contentline]) – The raw iCalendar data to parse, either as bytes or a list of content lines.component_factory (
ComponentFactory) – The factory to use for creating components.types_factory (
TypesFactory) – The factory to use for creating property values.
- get_subcomponent_parser(content_lines)[source]#
Get the parser for a subcomponent.
- Parameters:
content_lines (
list[Contentline]) – The content lines of the subcomponent.- Return type:
- handle_lazy_begin_component(component_name)[source]#
Begin a new component, but do not parse it yet.
- class icalendar.parser.ical.lazy.LazySubcomponent(name, parser)[source]#
Bases:
objectA subcomponent that is evaluated lazily.
This class holds the raw data of the subcomponent ready for parsing.
Initialize the lazy subcomponent with the raw data.
- is_lazy()[source]#
Return whether the subcomponents were accessed and parsed lazily.
Call
parse()to get the fully parsed component.- Return type:
- property name: str#
The name of the subcomponent.
The name is uppercased, per RFC 5545 Section 2.1.