icalendar.param module#

Parameter access for icalendar.

Related:

icalendar.param.RSVP = <property object>#

Indicate whether a reply is expected from the ATTENDEE.

The RSVP Expectation parameter can be specified on properties with a CAL-ADDRESS value type, specifically ATTENDEE, as part of the attendees property. An organizer uses it to request a participation status reply from an attendee in a group-scheduled event or to-do.

Note

According to RFC 5545 Section 3.2.17, if the parameter is absent from the property, it should return a value of False. However, it currently raises a KeyError. See #1778.

Example

Create a VCALADDRESS with an attendee who's expected to respond.

>>> from icalendar import vCalAddress
>>> attendee = vCalAddress("mailto:someone@example.com")
>>> attendee.params["RSVP"] = True
>>> attendee.params["RSVP"]
True
icalendar.param.boolean_parameter(name, default)[source]#

Create a property for a Boolean parameter.

Parameters:
  • default (bool) – The value to return when the parameter is absent.

  • name (str) – The parameter name in the params dictionary.

Return type:

property

Returns:

A property with a getter, setter, and deleter for the parameter.

icalendar.param.quoted_list_parameter(name)[source]#

Create a property for a parameter that contains a quoted list.

Parameters:

name (str) – The parameter name in the params dictionary.

Return type:

property

Returns:

A property with a getter, setter, and deleter for the parameter.

icalendar.param.string_parameter(name, doc, default=<function _default_return_none>, convert=None, convert_to=None)[source]#

Create a property for a string parameter with optional conversion.

This helper function is used to define properties that read from and write to self.params while optionally converting values between their stored string representation and a more convenient Python type.

Parameters:
  • name (str) – Name of the parameter in the params dictionary.

  • doc (str) – Documentation for the property.

  • default (Callable) – Function that returns a default value if the parameter is not found.

  • convert (Callable[[str], T] | None) – Function that converts the stored string value to the desired type.

  • convert_to (Callable[[T], str] | None) – Function to convert a value back to a string for storage.

Return type:

property

Returns:

A property object with a getter, setter, and deleter for the parameter.

Example

Define a parameter that is stored as a string but used as an integer:

>>> from icalendar.param import string_parameter
>>> class Dummy:
...     def __init__(self):
...         self.params = {}
...
>>> Dummy.priority = string_parameter(
...     "PRIORITY",
...     "Priority of the component",
...     default=lambda: 0,
...     convert=int,
...     convert_to=str,
... )
>>> obj = Dummy()

Accessing the property converts the stored string value to the type specified by the convert parameter, in this case, an int.

>>> obj.priority = "5"
>>> obj.priority
5

Setting the property stores the new value.

>>> obj.priority = 10
>>> obj.priority
10