icalendar.attr package#
Submodules#
Module contents#
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.
- icalendar.attr.get_duration_property(component)[source]#
Get the duration property with fallback calculation from start and end.
- icalendar.attr.get_end_property(component, end_property)[source]#
Get the end property with fallback logic for
EventandTodocomponents.- Parameters:
- Return type:
- 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 (
Event|Todo) – The component to validate, eitherEventorTodo.start_property (
Literal['DTSTART']) – The start property name,DTSTART.end_property (
Literal['DTEND','DUE']) – The end property name, eitherDTENDforEventorDUEforTodo.component_name (
Literal['VEVENT','VTODO']) – 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 (
Event|Todo) – The component from which to get its start property.- Return type:
- 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.
- 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:
- icalendar.attr.set_duration_with_locking(component, duration, locked, end_property)[source]#
Set the duration with explicit locking behavior for
EventandTodo.- Parameters:
component (
Event|Todo) – 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 (
Literal['DTEND','DUE']) – The end property name, eitherDTENDforEventorDUEforTodo.
- Return type:
- 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:
- Return type:
- icalendar.attr.set_start_with_locking(component, start, locked, end_property)[source]#
Set the start with explicit locking behavior for
EventandTodocomponents.- Parameters:
component (
Event|Todo) – The component to modify, eitherEventorTodo.locked (
Literal['duration','end'] |None) – Which property to keep unchanged, eitherduration,end, orNonefor auto-detect.end_property (
Literal['DTEND','DUE']) – The end property name, eitherDTENDforEventorDUEforTodo.
- Return type:
- icalendar.attr.single_int_property(prop, default, doc, *, min_value=None)[source]#
Create a property for an int value that exists only once.
- Parameters:
- Return type:
Added in version 7.3.0: Added the
min_valueparameter.
- 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:
- icalendar.attr.single_string_property(name, docs, other_name=None, default='', validate=None)[source]#
Create a property to access a single string value.
- Parameters:
docs (
str) – Required. Documentation string for the generated property.name (
str) – Required. The iCalendar property name, such as UID.default (
str) – Value returned when the property is not set.other_name (
str|list[str] |None) – One or more alias names to fall back on when the primary name is not present in the component.validate (
Callable[[str],None] |None) – Callable that receives the string form of the value and raises an exception if it does not conform to the expected format. It is called on set, before any existing value is removed, and must not modify the value.
- Return type:
- icalendar.attr.single_utc_property(name, docs)[source]#
Create a property to access a value of datetime in UTC timezone.
- icalendar.attr.validate_uid(value)[source]#
Validate the given value as a well-formed UID.
When set, the value must be an RFC 5545 Section 3.1 iana-token consisting of only ASCII letters, digits, and hyphens, and shorter than 255 octets, as required by RFC 7986 Section 5.3.
- Parameters:
value (
str) – The string form of the UID to validate.- Raises:
InvalidCalendar – If
valueis not compliant with RFC 5545 Section 3.1 as an iana-token or is 255 octets or longer.- Return type: