icalendar.cal.available module#

This implements the sub-component "AVAILABLE" of "VAVAILABILITY".

This is specified in RFC 7953.

class icalendar.cal.available.Available(*args, **kwargs)[source]#

Bases: Component

Sub-component of "VAVAILABILITY from RFC 7953.

Description:

"AVAILABLE" subcomponents are used to indicate periods of free time within the time range of the enclosing "VAVAILABILITY" component. "AVAILABLE" subcomponents MAY include recurrence properties to specify recurring periods of time, which can be overridden using normal iCalendar recurrence behavior (i.e., use of the "RECURRENCE-ID" property).

Examples

This is a recurring "AVAILABLE" subcomponent:

BEGIN:AVAILABLE
UID:57DD4AAF-3835-46B5-8A39-B3B253157F01
SUMMARY:Monday to Friday from 9:00 to 17:00
DTSTART;TZID=America/Denver:20111023T090000
DTEND;TZID=America/Denver:20111023T170000
RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR
LOCATION:Denver
END:AVAILABLE

You can get the same example from example():

property DTEND: datetime | None#

End of the component as a datetime in UTC.

This is almost the same as Event.DTEND with one exception: The values MUST have a timezone and DATE is not allowed.

Description:

RFC 7953: If specified, the "DTSTART" and "DTEND" properties in "VAVAILABILITY" components and "AVAILABLE" subcomponents MUST be "DATE-TIME" values specified as either the date with UTC time or the date with local time and a time zone reference.

property DTSTART: datetime | None#

Start of the component as a datetime in UTC.

This is almost the same as Event.DTSTART with one exception: The values MUST have a timezone and DATE is not allowed.

Description:

RFC 7953: If specified, the "DTSTART" and "DTEND" properties in "VAVAILABILITY" components and "AVAILABLE" subcomponents MUST be "DATE-TIME" values specified as either the date with UTC time or the date with local time and a time zone reference.

property DURATION: timedelta | None#

The DURATION property.

The "DTSTART" property for a "Available" specifies the inclusive start of the Available. The "DURATION" property in conjunction with the DTSTART property for a "Available" calendar component specifies the non-inclusive end of the event.

If you would like to calculate the duration of a Available, do not use this. Instead use the duration property (lower case).

property RECURRENCE_ID: date | datetime | None#

The RECURRENCE-ID property.

Identify a specific occurrence of a recurring calendar object.

This property is used together with UID and SEQUENCE to refer to one particular instance in a recurrence set. The value is the original start date or datetime of that instance, not the rescheduled time.

The value is usually a DATE-TIME and must use the same value type as the DTSTART property in the same component. A DATE value may be used for all-day items instead.

This property corresponds to RECURRENCE-ID as defined in RFC 5545 and may appear in recurring VEVENT, VTODO, and VJOURNAL components.

To delete the value, either use del or set it to None.

Raises:

InvalidCalendar: if the attribute has invalid values.

property categories: list[str]#

This property defines the categories for a component.

The categories property is used to specify categories or subtypes of the calendar component. The categories are useful to search for a calendar component of a particular type and category.

Within the calendar components, specify categories as a list of strings. You can get, set, and delete categories for a component.

This property can be used in icalendar through its Python attributes of:

The categories property for Available and Availability complies with RFC 7953 Section 3.1, for Event, Journal, and Todo with RFC 5545 Section 3.8.1.2, and for Calendar with RFC 7986 Section 5.6.

Note

At present, icalendar doesn't take the LANGUAGE parameter as defined in RFC 5545 Section 3.2.10 into account.

Parameters:

categories (list[str]) – A list of categories as strings.

Example

Create an event, add categories to it, print its ical representation, append another category, and finally compare the result against its expected value.

>>> from icalendar import Event
>>> event = Event()
>>> event.categories = ["Work", "Meeting"]
>>> print(event.to_ical())
BEGIN:VEVENT
CATEGORIES:Work,Meeting
END:VEVENT
>>> event.categories.append("Lecture")
>>> event.categories == ["Work", "Meeting", "Lecture"]
True

See also

Component.concepts

Setter accepts:

Sequence[str] | None

property contacts: list[str]#

Contact information associated with a calendar component.

The contact property holds free-text information for reaching the person or organization responsible in a component, such as a name, phone number, or a reference to more detailed contact data. Calendar clients surface it so attendees know who to contact about the event or task.

This property is defined in RFC 5545 Section 3.8.4.2 and may appear on a VEVENT, VTODO, VJOURNAL, or VFREEBUSY component. For availability components it is defined in RFC 7953 and may appear on a VAVAILABILITY or VAVAILABLE component. An alternate representation may point to a URI, for example, a vCard per RFC 2426, via the ALTREP parameter.

You can get, set, append, and delete contacts on a component. The value is a list of strings; each string is one contact entry.

Example

Add a contact to an event and then read it back.

>>> from icalendar import Event
>>> event = Event()
>>> event.add("CONTACT", "Jim Dolittle, ABC Industries, +1-919-555-1234")
>>> [str(c) for c in event.contacts]
['Jim Dolittle, ABC Industries, +1-919-555-1234']
>>> str(event.contacts[0])
'Jim Dolittle, ABC Industries, +1-919-555-1234'
Setter accepts:

str | Sequence[str] | None

property description: str | None#

DESCRIPTION provides a more complete description of the calendar component than that provided by the "SUMMARY" property.

Property Parameters:

IANA, non-standard, alternate text representation, and language property parameters can be specified on this property.

Conformance:

The property can be specified in the "VEVENT", "VTODO", "VJOURNAL", or "VALARM" calendar components. The property can be specified multiple times only within a "VJOURNAL" calendar component.

Description:

This property is used in the "VEVENT" and "VTODO" to capture lengthy textual descriptions associated with the activity.

This property is used in the "VALARM" calendar component to capture the display text for a DISPLAY category of alarm, and to capture the body text for an EMAIL category of alarm.

Examples

The following is an example of this property with formatted line breaks in the property value:

DESCRIPTION:Meeting to provide technical review for "Phoenix"
 design.\nHappy Face Conference Room. Phoenix design team
 MUST attend this meeting.\nRSVP to team leader.
property duration: timedelta | None#

Compute the duration of this component.

If there is no DTEND or DURATION set, this is None. Otherwise, the duration is calculated from DTSTART and DTEND/DURATION.

This is in accordance with RFC 7953: If "DTEND" or "DURATION" are not present, then the end time is unbounded.

property end: timedelta | None#

Compute the duration of this component.

If there is no DTEND or DURATION set, this is None. Otherwise, the duration is calculated from DTSTART and DTEND/DURATION.

This is in accordance with RFC 7953: If "DTEND" or "DURATION" are not present, then the end time is unbounded.

Setter accepts:

datetime

classmethod example(name='rfc_7953_1')[source]#

Return the calendar example with the given name.

Return type:

Available

property location: str | None#

The intended venue for the activity defined by a calendar component.

Property Parameters:

IANA, non-standard, alternate text representation, and language property parameters can be specified on this property.

Conformance:

Since RFC 5545, this property can be specified in "VEVENT" or "VTODO" calendar component. RFC 7953 adds this property to "VAVAILABILITY" and "VAVAILABLE".

Description:

Specific venues such as conference or meeting rooms may be explicitly specified using this property. An alternate representation may be specified that is a URI that points to directory information with more structured specification of the location. For example, the alternate representation may specify either an LDAP URL RFC 4516 pointing to an LDAP server entry or a CID URL RFC 2392 pointing to a MIME body part containing a Virtual-Information Card (vCard) RFC 2426 for the location.

name: ClassVar[str | None] = 'AVAILABLE'#

The name of the component.

This is defined in each component class.

Example

>>> from icalendar import Calendar
>>> cal = Calendar.new()
>>> cal.name
'VCALENDAR'
classmethod new(categories=(), comments=None, concepts=None, contacts=None, created=None, description=None, end=None, last_modified=None, links=None, location=None, recurrence_id=None, refids=None, related_to=None, sequence=None, stamp=None, start=None, summary=None, uid=None)[source]#

Create a new Available component with all required properties.

This creates a new Available component in accordance with RFC 7953.

Parameters:
Return type:

Self

Returns:

Available

Raises:

InvalidCalendar – If the content is not valid according to RFC 7953.

Warning

As time progresses, we will be stricter with the validation.

property sequence: int#

This property defines the revision sequence number of the calendar component within a sequence of revisions.

Value Type:

INTEGER

Property Parameters:

IANA and non-standard property parameters can be specified on this property.

Conformance:

The property can be specified in "VEVENT", "VTODO", or "VJOURNAL" calendar component.

Description:

When a calendar component is created, its sequence number is 0. It is monotonically incremented by the "Organizer's" CUA each time the "Organizer" makes a significant revision to the calendar component.

The "Organizer" includes this property in an iCalendar object that it sends to an "Attendee" to specify the current version of the calendar component.

The "Attendee" includes this property in an iCalendar object that it sends to the "Organizer" to specify the version of the calendar component to which the "Attendee" is referring.

A change to the sequence number is not the mechanism that an "Organizer" uses to request a response from the "Attendees". The "RSVP" parameter on the "ATTENDEE" property is used by the "Organizer" to indicate that a response from the "Attendees" is requested.

Recurrence instances of a recurring component MAY have different sequence numbers.

Examples

The following is an example of this property for a calendar component that was just created by the "Organizer":

>>> from icalendar import Event
>>> event = Event()
>>> event.sequence
0

The following is an example of this property for a calendar component that has been revised 10 different times by the "Organizer":

>>> from icalendar import Calendar
>>> calendar = Calendar.example("issue_156_RDATE_with_PERIOD_TZID_khal")
>>> event = calendar.events[0]
>>> event.sequence
10
Raises:
TypeError: If the value is not an int. Booleans are rejected, too,

even though bool subclasses int.

~icalendar.error.InvalidCalendar: If the value is negative.

Changed in version 7.3.0: Negative values are no longer accepted.

Setter accepts:

int | None

property start: datetime | None#

Start of the component as a datetime in UTC.

This is almost the same as Event.DTSTART with one exception: The values MUST have a timezone and DATE is not allowed.

Description:

RFC 7953: If specified, the "DTSTART" and "DTEND" properties in "VAVAILABILITY" components and "AVAILABLE" subcomponents MUST be "DATE-TIME" values specified as either the date with UTC time or the date with local time and a time zone reference.

property summary: str | None#

SUMMARY defines a short summary or subject for the calendar component.

Property Parameters:

IANA, non-standard, alternate text representation, and language property parameters can be specified on this property.

Conformance:

The property can be specified in "VEVENT", "VTODO", "VJOURNAL", or "VALARM" calendar components.

Description:

This property is used in the "VEVENT", "VTODO", and "VJOURNAL" calendar components to capture a short, one-line summary about the activity or journal entry.

This property is used in the "VALARM" calendar component to capture the subject of an EMAIL category of alarm.

Examples

The following is an example of this property:

SUMMARY:Department Party
property uid: str#

UID specifies the persistent, globally unique identifier for a component.

We recommend using uuid.uuid4() to generate new values.

Returns:

The value of the UID property as a string or "" if no value is set.

Description:

The "UID" itself MUST be a globally unique identifier. The generator of the identifier MUST guarantee that the identifier is unique.

This is the method for correlating scheduling messages with the referenced "VEVENT", "VTODO", or "VJOURNAL" calendar component. The full range of calendar components specified by a recurrence set is referenced by referring to just the "UID" property value corresponding to the calendar component. The "RECURRENCE-ID" property allows the reference to an individual instance within the recurrence set.

This property is an important method for group-scheduling applications to match requests with later replies, modifications, or deletion requests. Calendaring and scheduling applications MUST generate this property in "VEVENT", "VTODO", and "VJOURNAL" calendar components to assure interoperability with other group- scheduling applications. This identifier is created by the calendar system that generates an iCalendar object.

Implementations MUST be able to receive and persist values of at least 255 octets for this property, but they MUST NOT truncate values in the middle of a UTF-8 multi-octet sequence.

RFC 7986 states that UID can be used, for example, to identify duplicate calendar streams that a client may have been given access to. It can be used in conjunction with the "LAST-MODIFIED" property also specified on the "VCALENDAR" object to identify the most recent version of a calendar.

Conformance:

RFC 5545 states that the "UID" property can be specified on "VEVENT", "VTODO", and "VJOURNAL" calendar components. RFC 7986 modifies the definition of the "UID" property to allow it to be defined in an iCalendar object. RFC 9074 adds a "UID" property to "VALARM" components to allow a unique identifier to be specified. The value of this property can then be used to refer uniquely to the "VALARM" component.

This property can be specified once only.

Security:

RFC 7986 states that UID values MUST NOT include any data that might identify a user, host, domain, or any other security- or privacy-sensitive information. It is RECOMMENDED that calendar user agents now generate "UID" values that are hex-encoded random Universally Unique Identifier (UUID) values as defined in Sections 4.4 and 4.5 of RFC 4122. You can use the uuid module to generate new UUIDs.

Compatibility:

For Alarms, X-ALARMUID is also considered.

Examples

The following is an example of such a property value: 5FC53010-1267-4F8E-BC28-1D7AE55A7C99.

Set the UID of a calendar:

>>> from icalendar import Calendar
>>> from uuid import uuid4
>>> calendar = Calendar()
>>> calendar.uid = uuid4()
>>> print(calendar.to_ical())
BEGIN:VCALENDAR
UID:d755cef5-2311-46ed-a0e1-6733c9e15c63
END:VCALENDAR
Setter accepts:

str | None