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.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
andTodo
components.- Parameters:
component – The component to get end from
end_property – The end property name, either
DTEND
forEvent
orDUE
forTodo
.
- 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
andTodo
components.- Parameters:
component – The component to validate, either
Event
orTodo
.start_property – The start property name,
DTSTART
.end_property – The end property name, either
DTEND
forEvent
orDUE
forTodo
.component_name – The component name for error messages, either
VEVENT
orVTODO
.
- Returns:
(start, end, duration) values from the component.
- Return type:
- 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.
- 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
andTodo
.- Parameters:
component – The component to modify, either
Event
orTodo
.duration – The duration to set, or
None
to convert toDURATION
property.locked – Which property to keep unchanged, either
start
orend
.end_property – The end property name, either
DTEND
forEvent
orDUE
forTodo
.
- 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
orTodo
.end – The end time to set.
locked – Which property to keep unchanged, either
start
orduration
.end_property – The end property name, either
DTEND
forEvent
orDUE
forTodo
.
- 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
andTodo
components.- Parameters:
component – The component to modify, either
Event
orTodo
.start – The start time to set.
locked – Which property to keep unchanged, either
duration
,end
, orNone
for auto-detect.end_property – The end property name, either
DTEND
forEvent
orDUE
forTodo
.