icalendar.attr module#

Attributes of Components and properties.

icalendar.attr.create_single_property(prop, value_attr, value_type, type_def, doc, vProp=<class 'icalendar.prop.vDDDTypes'>)[source]#

Create a single property getter and setter.

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

  • value_attr (Optional[str]) – The name of the attribute to get the value from.

  • value_type (tuple[type]) – The type of the value.

  • type_def (type) – The type of the property.

  • doc (str) – The docstring of the property.

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

icalendar.attr.duration_property(component)[source]#

Return the duration property.

Return type:

property

icalendar.attr.get_duration_property(component)[source]#

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

Parameters:

component (Component) – The component from which to get its duration property.

Return type:

timedelta

Returns:

The duration as a timedelta.

icalendar.attr.get_end_property(component, end_property)[source]#

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

Parameters:
  • component (Component) – The component to get end from

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

Return type:

date | datetime

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, start_property, end_property, component_name)[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 (Component) – The component to validate, either Event or Todo.

  • start_property (str) – The start property name, DTSTART.

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

  • component_name (str) – 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)[source]#

Get the start property with validation.

Parameters:

component (Component) – The component from which to get its start property.

Return type:

date | datetime

Returns:

The DTSTART value.

Raises:

IncompleteComponent – If no DTSTART is present.

icalendar.attr.multi_language_text_property(main_prop, compatibility_prop, doc)[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

Return type:

property

icalendar.attr.multi_string_property(name, doc)[source]#

A property for an iCalendar Property that can occur multiple times.

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

Delete property DURATION.

icalendar.attr.property_get_duration(self)[source]#

Getter for property DURATION.

Return type:

Optional[timedelta]

icalendar.attr.property_set_duration(self, value)[source]#

Setter for property DURATION.

icalendar.attr.set_duration_with_locking(component, duration, locked, end_property)[source]#

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

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

  • duration (timedelta | None) – The duration to set, or None to convert to DURATION property.

  • locked (Literal['start', 'end']) – Which property to keep unchanged, either start or end.

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

Return type:

None

icalendar.attr.set_end_with_locking(component, end, locked, end_property)[source]#

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

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

  • end (date | datetime) – The end time to set.

  • locked (Literal['start', 'duration']) – Which property to keep unchanged, either start or duration.

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

Return type:

None

icalendar.attr.set_start_with_locking(component, start, locked, end_property)[source]#

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

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

  • start (date | datetime) – The start time to set.

  • locked (Optional[Literal['duration', 'end']]) – Which property to keep unchanged, either duration, end, or None for auto-detect.

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

Return type:

None

icalendar.attr.single_int_property(prop, default, doc)[source]#

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

Parameters:
  • prop (str) – The name of the property

  • default (int) – The default value

  • doc (str) – The documentation string

Return type:

property

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

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

Parameters:
  • name (str) – name of the property

  • docs (str) – documentation string

Return type:

property