icalendar.attr module#

Attributes of Components and properties.

icalendar.attr.create_single_property(prop: str, value_attr: str | None, value_type: tuple[type], type_def: type, doc: str, vProp: type = <class 'icalendar.prop.vDDDTypes'>)[source]#

Create a single property getter and setter.

Parameters:
  • prop – The name of the property.

  • value_attr – The name of the attribute to get the value from.

  • value_type – The type of the value.

  • type_def – The type of the property.

  • doc – The docstring of the property.

  • vProp – The type of the property from icalendar.prop.

icalendar.attr.duration_property(component: str) property[source]#

Return the duration property.

icalendar.attr.get_duration_property(component: Component) timedelta[source]#

Get the duration property with fallback calculation from start and end.

Parameters:

component – The component from which to get its duration property.

Returns:

The duration as a timedelta.

icalendar.attr.get_end_property(component: Component, end_property: str) date | datetime[source]#

Get the end property with fallback logic for Event and Todo components.

Parameters:
  • component – The component to get end from

  • end_property – The end property name, either DTEND for Event or DUE for Todo.

Returns:

The computed end value.

Raises:

IncompleteComponent – If the provided information is incomplete to compute the end property.

icalendar.attr.get_start_end_duration_with_validation(component: Component, start_property: str, end_property: str, component_name: str) tuple[date | datetime | None, date | datetime | None, timedelta | None][source]#

Validate the component and return start, end, and duration.

This tests validity according to RFC 5545 rules for Event and Todo components.

Parameters:
  • component – The component to validate, either Event or Todo.

  • start_property – The start property name, DTSTART.

  • end_property – The end property name, either DTEND for Event or DUE for Todo.

  • component_name – The component name for error messages, either VEVENT or VTODO.

Returns:

(start, end, duration) values from the component.

Return type:

tuple

Raises:

InvalidCalendar – If the component violates RFC 5545 constraints.

icalendar.attr.get_start_property(component: Component) date | datetime[source]#

Get the start property with validation.

Parameters:

component – The component from which to get its start property.

Returns:

The DTSTART value.

Raises:

IncompleteComponent – If no DTSTART is present.

icalendar.attr.multi_language_text_property(main_prop: str, compatibility_prop: str | None, doc: str) property[source]#

This creates a text property.

This property can be defined several times with different LANGUAGE parameters.

Parameters:
  • main_prop (str) – The property to set and get, such as NAME

  • compatibility_prop (str) – An old property used before, such as X-WR-CALNAME

  • doc (str) – The documentation string

icalendar.attr.property_del_duration(self: Component)[source]#

Delete property DURATION.

icalendar.attr.property_get_duration(self: Component) timedelta | None[source]#

Getter for property DURATION.

icalendar.attr.property_set_duration(self: Component, value: timedelta | None)[source]#

Setter for property DURATION.

icalendar.attr.set_duration_with_locking(component: Component, duration: timedelta | None, locked: Literal['start', 'end'], end_property: str) None[source]#

Set the duration with explicit locking behavior for Event and Todo.

Parameters:
  • component – The component to modify, either Event or Todo.

  • duration – The duration to set, or None to convert to DURATION property.

  • locked – Which property to keep unchanged, either start or end.

  • end_property – The end property name, either DTEND for Event or DUE for Todo.

icalendar.attr.set_end_with_locking(component: Component, end: date | datetime, locked: Literal['start', 'duration'], end_property: str) None[source]#

Set the end with explicit locking behavior for Event and Todo components.

Parameters:
  • component – The component to modify, either Event or Todo.

  • end – The end time to set.

  • locked – Which property to keep unchanged, either start or duration.

  • end_property – The end property name, either DTEND for Event or DUE for Todo.

icalendar.attr.set_start_with_locking(component: Component, start: date | datetime, locked: Literal['duration', 'end'] | None, end_property: str) None[source]#

Set the start with explicit locking behavior for Event and Todo components.

Parameters:
  • component – The component to modify, either Event or Todo.

  • start – The start time to set.

  • locked – Which property to keep unchanged, either duration, end, or None for auto-detect.

  • end_property – The end property name, either DTEND for Event or DUE for Todo.

icalendar.attr.single_int_property(prop: str, default: int, doc: str) property[source]#

Create a property for an int value that exists only once.

Parameters:
  • prop – The name of the property

  • default – The default value

  • doc – The documentation string

icalendar.attr.single_utc_property(name: str, docs: str) property[source]#

Create a property to access a value of datetime in UTC timezone.

Parameters:
  • name – name of the property

  • docs – documentation string