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.dt.types.vDDDTypes'>, convert=None)[source]#
Create a single property getter and setter.
- Parameters:
prop (
str) – The name of the property.value_attr (
str|None) – 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 fromicalendar.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
EventandTodocomponents.- Parameters:
component (
Component) – The component to get end fromend_property (
str) – The end property name, eitherDTENDforEventorDUEforTodo.
- 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
EventandTodocomponents.- Parameters:
component (
Component) – The component to validate, eitherEventorTodo.start_property (
str) – The start property name,DTSTART.end_property (
str) – The end property name, eitherDTENDforEventorDUEforTodo.component_name (
str) – The component name for error messages, eitherVEVENTorVTODO.
- Returns:
(start, end, duration) values from the component.
- Return type:
tuple[date|datetime|None,date|datetime|None,timedelta|None]- 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
DTSTARTvalue.- Raises:
IncompleteComponent – If no
DTSTARTis 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
LANGUAGEparameters.- Parameters:
main_prop (
str) – The property to set and get, such asNAMEcompatibility_prop (
str|None) – An old property used before, such asX-WR-CALNAMEdoc (
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.multi_text_property(name, docs)[source]#
Get a property that can occur several times and is text.
Examples: Journal.descriptions, Event.comments
- Return type:
property
- icalendar.attr.property_get_duration(self)[source]#
Getter for property DURATION.
- Return type:
timedelta|None
- icalendar.attr.set_duration_with_locking(component, duration, locked, end_property)[source]#
Set the duration with explicit locking behavior for
EventandTodo.- Parameters:
component (
Component) – The component to modify, eitherEventorTodo.duration (
timedelta|None) – The duration to set, orNoneto convert toDURATIONproperty.locked (
Literal['start','end']) – Which property to keep unchanged, eitherstartorend.end_property (
str) – The end property name, eitherDTENDforEventorDUEforTodo.
- 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, eitherEventorTodo.end (
date|datetime) – The end time to set.locked (
Literal['start','duration']) – Which property to keep unchanged, eitherstartorduration.end_property (
str) – The end property name, eitherDTENDforEventorDUEforTodo.
- Return type:
None
- icalendar.attr.set_start_with_locking(component, start, locked, end_property)[source]#
Set the start with explicit locking behavior for
EventandTodocomponents.- Parameters:
component (
Component) – The component to modify, eitherEventorTodo.start (
date|datetime) – The start time to set.locked (
Literal['duration','end'] |None) – Which property to keep unchanged, eitherduration,end, orNonefor auto-detect.end_property (
str) – The end property name, eitherDTENDforEventorDUEforTodo.
- Return type:
None
- icalendar.attr.single_int_property(prop, default, doc, *, min_value=None)[source]#
Create a property for an int value that exists only once.
- Parameters:
default (
int) – Required. The default value.doc (
str) – Required. The documentation string.prop (
str) – Required. The name of the property.min_value (
int|None) – If set, the value must be greater than or equal to this minimum.
Added in version 7.2.3: Added the
min_valueparameter.- Return type:
property
- icalendar.attr.single_string_enum_property(name, enum, default, docs)[source]#
Create a property to access a single string value and convert it to an enum.
- Return type:
property