icalendar.parser.ical.component module#

Parsing a component's iCalendar data.

class icalendar.parser.ical.component.ComponentIcalParser(data, component_factory, types_factory)[source]#

Bases: object

A parser for a component's iCalendar data.

This uses the template method pattern, where the main parsing logic can be refined in subclasses.

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.

property component: Component | None#
contains_component(name)[source]#

Check if the parser contains a component.

Return type:

bool

contains_uid(uid)[source]#

Determines whether the component contains a uid.

Return type:

bool

Returns:

True if the component contains a uid, else False.

datetime_names: ClassVar[tuple[str, ...]] = ('DTSTART', 'DTEND', 'RECURRENCE-ID', 'DUE', 'RDATE', 'EXDATE')#

Names to check for TZID parameter when parsing datetimes.

Their from_ical methods take an optional tzid argument, which is used if the property has a TZID parameter.

get_factory_for_property(name, params)[source]#

Get the factory for a property.

Return type:

vAdr | vBoolean | vBroken | vCalAddress | vCategory | vDDDLists | vDDDTypes | vDate | vDatetime | vDuration | vFloat | vFrequency | vInt | vMonth | vN | vOrg | vPeriod | vRecur | vSkip | vText | vTime | vUTCOffset | vUri | vWeekday | vInline | vBinary | vGeo | vUnknown | vXmlReference | vUid

handle_begin_component(vals)[source]#

Handle the beginning of a component.

Return type:

None

handle_categories(params, vals, line)[source]#

Handle the special case of CATEGORIES property.

Return type:

bool

Returns:

True if handled, else False.

handle_end_component(vals)[source]#

Handle the end of a component.

Return type:

None

handle_line_parse_error(exception)[source]#

Handle a line parsing error.

handle_property(name, params, vals, line)[source]#

Handle a property line.

Add properties to the top of the current stack.

Parameters:
  • name (str) – The name of the property, uppercased.

  • params (Parameters) – The parameters of the property.

  • vals (str) – The value of the property.

  • line (Contentline) – The original content line.

Return type:

None

handle_property_parse_error(exception, name, params, val, line)[source]#

Handle the parse error for a property.

initialize_parsing()[source]#
parse()[source]#

Parse the raw data.

Return type:

list[Component]

parse_and_add_property(name, params, val, tzid, line)[source]#

Parse a property value and add it to the current component.

parse_content_lines()[source]#

Parse the content lines.

Return type:

None

prepare_components()[source]#

Prepare the parsed components.

This is called when all components are parsed.

Return type:

None