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
attendeesproperty. 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 aKeyError. 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.
- icalendar.param.quoted_list_parameter(name)[source]#
Create a property for a parameter that contains a quoted list.
- 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.paramswhile 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:
- 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
convertparameter, in this case, anint.>>> obj.priority = "5" >>> obj.priority 5
Setting the property stores the new value.
>>> obj.priority = 10 >>> obj.priority 10