Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/icalendar/param.py: 53%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""Parameter access for icalendar.
3Related:
5- :rfc:`5545`, Section 3.2. Property Parameters
6- :rfc:`7986`, Section 6. Property Parameters
7- :rfc:`9253`
8- https://github.com/collective/icalendar/issues/798
9"""
11from __future__ import annotations
13import functools
14from typing import TYPE_CHECKING, TypeVar
16from icalendar import enums
18if TYPE_CHECKING:
19 from collections.abc import Callable
20 from datetime import timedelta
21 from enum import Enum
24if TYPE_CHECKING:
25 from icalendar.prop import VPROPERTY
28def _default_return_none() -> str | None:
29 """Return None by default."""
30 return None
33def _default_return_string() -> str:
34 """Return None by default."""
35 return ""
38T = TypeVar("T")
41def string_parameter(
42 name: str,
43 doc: str,
44 default: Callable = _default_return_none,
45 convert: Callable[[str], T] | None = None,
46 convert_to: Callable[[T], str] | None = None,
47) -> property:
48 """Create a property for a string parameter with optional conversion.
50 This helper function is used to define properties that read from and write to
51 ``self.params`` while optionally converting values between their stored
52 string representation and a more convenient Python type.
54 Parameters:
55 name: Name of the parameter in the params dictionary.
56 doc: Documentation for the property.
57 default:
58 Function that returns a default value if the parameter is not found.
59 convert:
60 Function that converts the stored string value to the desired type.
61 convert_to:
62 Function to convert a value back to a string for storage.
64 Returns:
65 A property object with a getter, setter, and deleter for the parameter.
67 Example:
69 Define a parameter that is stored as a string but used as an integer:
71 >>> from icalendar.param import string_parameter
73 >>> class Dummy:
74 ... def __init__(self):
75 ... self.params = {}
76 ...
77 >>> Dummy.priority = string_parameter(
78 ... "PRIORITY",
79 ... "Priority of the component",
80 ... default=lambda: 0,
81 ... convert=int,
82 ... convert_to=str,
83 ... )
84 >>> obj = Dummy()
86 Accessing the property converts the stored string value to the type
87 specified by the ``convert`` parameter, in this case, an ``int``.
89 >>> obj.priority = "5"
90 >>> obj.priority
91 5
93 Setting the property stores the new value.
95 >>> obj.priority = 10
96 >>> obj.priority
97 10
98 """
100 if convert_to is None:
101 convert_to = convert
103 @functools.wraps(default)
104 def fget(self: VPROPERTY) -> str | None:
105 value = self.params.get(name)
106 if value is None:
107 return default()
108 return convert(value) if convert else value
110 def fset(self: VPROPERTY, value: str | None):
111 if value is None:
112 fdel(self)
113 else:
114 self.params[name] = convert_to(value) if convert_to else value
116 def fdel(self: VPROPERTY):
117 self.params.pop(name, None)
119 return property(fget, fset, fdel, doc=doc)
122ALTREP = string_parameter(
123 "ALTREP",
124 """ALTREP - Specify an alternate text representation for the property value.
126Description:
127 This parameter specifies a URI that points to an
128 alternate representation for a textual property value. A property
129 specifying this parameter MUST also include a value that reflects
130 the default representation of the text value. The URI parameter
131 value MUST be specified in a quoted-string.
133.. note::
135 While there is no restriction imposed on the URI schemes
136 allowed for this parameter, Content Identifier (CID) :rfc:`2392`,
137 HTTP :rfc:`2616`, and HTTPS :rfc:`2818` are the URI schemes most
138 commonly used by current implementations.
139""",
140)
142CN = string_parameter(
143 "CN",
144 """Specify the common name to be associated with the calendar user specified.
146Description:
147 This parameter can be specified on properties with a
148 CAL-ADDRESS value type. The parameter specifies the common name
149 to be associated with the calendar user specified by the property.
150 The parameter value is text. The parameter value can be used for
151 display text to be associated with the calendar address specified
152 by the property.
153""",
154 default=_default_return_string,
155)
158def _default_return_individual() -> enums.CUTYPE | str:
159 """Default value."""
160 return enums.CUTYPE.INDIVIDUAL
163def _convert_enum(enum: type[Enum]) -> Callable[[str], Enum]:
164 def convert(value: str) -> str:
165 """Convert if possible."""
166 try:
167 return enum(value.upper())
168 except ValueError:
169 return value
171 return convert
174CUTYPE = string_parameter(
175 "CUTYPE",
176 """Identify the type of calendar user specified by the property.
178Description:
179 This parameter can be specified on properties with a
180 CAL-ADDRESS value type. The parameter identifies the type of
181 calendar user specified by the property. If not specified on a
182 property that allows this parameter, the default is INDIVIDUAL.
183 Applications MUST treat x-name and iana-token values they don't
184 recognize the same way as they would the UNKNOWN value.
185""",
186 default=_default_return_individual,
187 convert=_convert_enum(enums.CUTYPE),
188)
191def quoted_list_parameter(name: str) -> property:
192 """Create a property for a parameter that contains a quoted list.
194 Parameters:
195 name: The parameter name in the ``params`` dictionary.
197 Returns:
198 A property with a getter, setter, and deleter for the parameter.
199 """
201 def fget(self: VPROPERTY) -> tuple[str]:
202 value = self.params.get(name)
203 if value is None:
204 return ()
205 if isinstance(value, str):
206 return tuple(value.split(","))
207 return value
209 def fset(self: VPROPERTY, value: str | tuple[str]):
210 if value == ():
211 fdel(self)
212 else:
213 self.params[name] = (value,) if isinstance(value, str) else value
215 def fdel(self: VPROPERTY):
216 self.params.pop(name, None)
218 return property(fget, fset, fdel)
221DELEGATED_FROM = quoted_list_parameter("DELEGATED-FROM")
223DELEGATED_TO = quoted_list_parameter("DELEGATED-TO")
225DIR = string_parameter(
226 "DIR",
227 """Specify reference to a directory entry associated with the calendar user specified by the property.
229Description:
230 This parameter can be specified on properties with a
231 CAL-ADDRESS value type. The parameter specifies a reference to
232 the directory entry associated with the calendar user specified by
233 the property. The parameter value is a URI. The URI parameter
234 value MUST be specified in a quoted-string.
236.. note::
238 While there is no restriction imposed on the URI schemes
239 allowed for this parameter, CID :rfc:`2392`, DATA :rfc:`2397`, FILE
240 :rfc:`1738`, FTP :rfc:`1738`, HTTP :rfc:`2616`, HTTPS :rfc:`2818`, LDAP
241 :rfc:`4516`, and MID :rfc:`2392` are the URI schemes most commonly
242 used by current implementations.
243""", # noqa: E501
244)
246EMAIL = string_parameter(
247 "EMAIL",
248 """Specify an email address for a calendar user.
250Description:
251 This parameter can be specified on the ``ORGANIZER`` and ``ATTENDEE``
252 properties. It provides an email address for identifying or contacting the
253 calendar user, which can differ from the calendar address value.
254 See :rfc:`7986#section-6.2`.
256 Returns ``None`` when absent. Assign ``None`` or delete this property to
257 remove the parameter.
259 This is distinct from :attr:`email`, which returns the
260 calendar address value without its ``mailto:`` prefix.
261""",
262)
265def _default_return_busy() -> enums.FBTYPE | str:
266 """Default value."""
267 return enums.FBTYPE.BUSY
270FBTYPE = string_parameter(
271 "FBTYPE",
272 """Specify the free or busy time type.
274Description:
275 This parameter specifies the free or busy time type.
276 The value FREE indicates that the time interval is free for
277 scheduling. The value BUSY indicates that the time interval is
278 busy because one or more events have been scheduled for that
279 interval. The value BUSY-UNAVAILABLE indicates that the time
280 interval is busy and that the interval can not be scheduled. The
281 value BUSY-TENTATIVE indicates that the time interval is busy
282 because one or more events have been tentatively scheduled for
283 that interval. If not specified on a property that allows this
284 parameter, the default is BUSY. Applications MUST treat x-name
285 and iana-token values they don't recognize the same way as they
286 would the BUSY value.
287""",
288 default=_default_return_busy,
289 convert=_convert_enum(enums.FBTYPE),
290)
292LANGUAGE = string_parameter(
293 "LANGUAGE",
294 """Specify the language for text values in a property or property parameter.
296Description:
297 This parameter identifies the language of the text in
298 the property value and of all property parameter values of the
299 property. The value of the "LANGUAGE" property parameter is that
300 defined in :rfc:`5646`.
302 For transport in a MIME entity, the Content-Language header field
303 can be used to set the default language for the entire body part.
304 Otherwise, no default language is assumed.
305""",
306)
308MEMBER = quoted_list_parameter("MEMBER")
311def _default_return_needs_action() -> enums.PARTSTAT | str:
312 """Default value."""
313 return enums.PARTSTAT.NEEDS_ACTION
316PARTSTAT = string_parameter(
317 "PARTSTAT",
318 """Specify the participation status for the calendar user specified by the property.
320Description:
321 This parameter can be specified on properties with a
322 CAL-ADDRESS value type. The parameter identifies the
323 participation status for the calendar user specified by the
324 property value. The parameter values differ depending on whether
325 they are associated with a group-scheduled "VEVENT", "VTODO", or
326 "VJOURNAL". The values MUST match one of the values allowed for
327 the given calendar component. If not specified on a property that
328 allows this parameter, the default value is NEEDS-ACTION.
329 Applications MUST treat x-name and iana-token values they don't
330 recognize the same way as they would the NEEDS-ACTION value.
331""",
332 default=_default_return_needs_action,
333 convert=_convert_enum(enums.PARTSTAT),
334)
337def _default_range_none() -> enums.RANGE | str | None:
338 return None
341RANGE = string_parameter(
342 "RANGE",
343 """Specify the effective range of recurrence instances from the instance specified by the recurrence identifier specified by the property.
345Description:
346 This parameter can be specified on a property that
347 specifies a recurrence identifier. The parameter specifies the
348 effective range of recurrence instances that is specified by the
349 property. The effective range is from the recurrence identifier
350 specified by the property. If this parameter is not specified on
351 an allowed property, then the default range is the single instance
352 specified by the recurrence identifier value of the property. The
353 parameter value can only be "THISANDFUTURE" to indicate a range
354 defined by the recurrence identifier and all subsequent instances.
355 The value "THISANDPRIOR" is deprecated by this revision of
356 iCalendar and MUST NOT be generated by applications.
357""", # noqa: E501
358 default=_default_range_none,
359 convert=_convert_enum(enums.RANGE),
360)
363def _default_related() -> enums.RELATED | str:
364 return enums.RELATED.START
367RELATED = string_parameter(
368 "RELATED",
369 """Specify the relationship of the alarm trigger with respect to the start or end of the calendar component.
371Description:
372 This parameter can be specified on properties that
373 specify an alarm trigger with a "DURATION" value type. The
374 parameter specifies whether the alarm will trigger relative to the
375 start or end of the calendar component. The parameter value START
376 will set the alarm to trigger off the start of the calendar
377 component; the parameter value END will set the alarm to trigger
378 off the end of the calendar component. If the parameter is not
379 specified on an allowable property, then the default is START.
381""", # noqa: E501
382 default=_default_related,
383 convert=_convert_enum(enums.RELATED),
384)
387def _default_req_participant() -> enums.ROLE | str:
388 return enums.ROLE.REQ_PARTICIPANT
391ROLE = string_parameter(
392 "ROLE",
393 """Specify the participation role for the calendar user specified by the property.
395Description:
396 This parameter can be specified on properties with a
397 CAL-ADDRESS value type. The parameter specifies the participation
398 role for the calendar user specified by the property in the group
399 schedule calendar component. If not specified on a property that
400 allows this parameter, the default value is REQ-PARTICIPANT.
401 Applications MUST treat x-name and iana-token values they don't
402 recognize the same way as they would the REQ-PARTICIPANT value.
403""",
404 default=_default_req_participant,
405 convert=_convert_enum(enums.ROLE),
406)
409def boolean_parameter(name: str, default: bool) -> property:
410 """Create a property for a Boolean parameter.
412 Parameters:
413 default: The value to return when the parameter is absent.
414 name: The parameter name in the ``params`` dictionary.
416 Returns:
417 A property with a getter, setter, and deleter for the parameter.
418 """
420 def _default() -> bool:
421 return default
423 return string_parameter(
424 name,
425 "",
426 default=_default,
427 convert=lambda x: x.upper() == "TRUE",
428 convert_to=lambda x: "TRUE" if x else "FALSE",
429 )
432RSVP = boolean_parameter("RSVP", False)
433"""Indicate whether a reply is expected from the ATTENDEE.
435The RSVP Expectation parameter can be specified on properties with a
436CAL-ADDRESS value type, specifically ATTENDEE, as part of the ``attendees``
437property. An organizer uses it to request a participation status reply from
438an attendee in a group-scheduled event or to-do.
440.. note::
442 According to :rfc:`5545#section-3.2.17`, if the parameter is absent from
443 the property, it should return a value of ``False``. However, it
444 currently raises a ``KeyError``. See :issue:`1778`.
446Example:
448 Create a VCALADDRESS with an attendee who's expected to respond.
450 .. code-block:: pycon
452 >>> from icalendar import vCalAddress
453 >>> attendee = vCalAddress("mailto:someone@example.com")
454 >>> attendee.params["RSVP"] = True
455 >>> attendee.params["RSVP"]
456 True
458.. seealso::
460 - :attr:`Alarm.attendees <icalendar.cal.alarm.Alarm.attendees>`
461 - :attr:`Event.attendees <icalendar.cal.event.Event.attendees>`
462 - :attr:`Journal.attendees <icalendar.cal.journal.Journal.attendees>`
463 - :attr:`Todo.attendees <icalendar.cal.todo.Todo.attendees>`
464"""
466SENT_BY = string_parameter(
467 "SENT-BY",
468 """Specify the calendar user that is acting on behalf of the calendar user specified by the property.
470Description:
471 This parameter can be specified on properties with a
472 CAL-ADDRESS value type. The parameter specifies the calendar user
473 that is acting on behalf of the calendar user specified by the
474 property. The parameter value MUST be a mailto URI as defined in
475 :rfc:`2368`. The individual calendar address parameter values MUST
476 each be specified in a quoted-string.
477""", # noqa: E501
478)
480TZID = string_parameter(
481 "TZID",
482 """Specify the identifier for the time zone definition for a time component in the property value.
484Description:
485 This parameter MUST be specified on the "DTSTART",
486 "DTEND", "DUE", "EXDATE", and "RDATE" properties when either a
487 DATE-TIME or TIME value type is specified and when the value is
488 neither a UTC or a "floating" time. Refer to the DATE-TIME or
489 TIME value type definition for a description of UTC and "floating
490 time" formats. This property parameter specifies a text value
491 that uniquely identifies the "VTIMEZONE" calendar component to be
492 used when evaluating the time portion of the property. The value
493 of the "TZID" property parameter will be equal to the value of the
494 "TZID" property for the matching time zone definition. An
495 individual "VTIMEZONE" calendar component MUST be specified for
496 each unique "TZID" parameter value specified in the iCalendar
497 object.
499 The parameter MUST be specified on properties with a DATE-TIME
500 value if the DATE-TIME is not either a UTC or a "floating" time.
501 Failure to include and follow VTIMEZONE definitions in iCalendar
502 objects may lead to inconsistent understanding of the local time
503 at any given location.
505 The presence of the SOLIDUS character as a prefix, indicates that
506 this "TZID" represents a unique ID in a globally defined time zone
507 registry (when such registry is defined).
509.. note::
511 This document does not define a naming convention for
512 time zone identifiers. Implementers may want to use the naming
513 conventions defined in existing time zone specifications such
514 as the public-domain TZ database (TZDB). The specification of
515 globally unique time zone identifiers is not addressed by this
516 document and is left for future study.
517""", # noqa: E501
518)
521def _default_return_parent() -> enums.RELTYPE:
522 return enums.RELTYPE.PARENT
525RELTYPE = string_parameter(
526 "RELTYPE",
527 """Specify the type of hierarchical relationship associated with a component.
529Conformance:
530 :rfc:`5545` introduces the RELTYPE property parameter.
531 :rfc:`9253` adds new values.
533Description:
534 This parameter can be specified on a property that
535 references another related calendar. The parameter specifies the
536 hierarchical relationship type of the calendar component
537 referenced by the property. The parameter value can be PARENT, to
538 indicate that the referenced calendar component is a superior of
539 calendar component; CHILD to indicate that the referenced calendar
540 component is a subordinate of the calendar component; or SIBLING
541 to indicate that the referenced calendar component is a peer of
542 the calendar component. If this parameter is not specified on an
543 allowable property, the default relationship type is PARENT.
544 Applications MUST treat x-name and iana-token values they don't
545 recognize the same way as they would the PARENT value.
546""",
547 default=_default_return_parent,
548 convert=_convert_enum(enums.RELTYPE),
549)
552def _get_value(self: VPROPERTY) -> str:
553 """The VALUE parameter or the default.
555 Purpose:
556 VALUE explicitly specify the value type format for a property value.
558 Description:
559 This parameter specifies the value type and format of
560 the property value. The property values MUST be of a single value
561 type. For example, a "RDATE" property cannot have a combination
562 of DATE-TIME and TIME value types.
564 If the property's value is the default value type, then this
565 parameter need not be specified. However, if the property's
566 default value type is overridden by some other allowable value
567 type, then this parameter MUST be specified.
569 Applications MUST preserve the value data for ``x-name`` and
570 ``iana-token`` values that they don't recognize without attempting
571 to interpret or parse the value data.
573 Returns:
574 The VALUE parameter or the default.
576 Examples:
577 The VALUE defaults to the name of the property.
578 Note that it is case-insensitive but always uppercase.
580 .. code-block:: pycon
582 >>> from icalendar import vBoolean
583 >>> b = vBoolean(True)
584 >>> b.VALUE
585 'BOOLEAN'
587 Setting the VALUE parameter of a typed property usually does not make sense.
588 For convenience, using this property, the value will be converted to
589 an uppercase string.
590 If you have some custom property, you might use it like this:
592 .. code-block:: pycon
594 >>> from icalendar import vUnknown, Event
595 >>> v = vUnknown("Some property text.")
596 >>> v.VALUE = "x-type" # lower case
597 >>> v.VALUE
598 'X-TYPE'
599 >>> event = Event()
600 >>> event.add("x-prop", v)
601 >>> print(event.to_ical())
602 BEGIN:VEVENT
603 X-PROP;VALUE=X-TYPE:Some property text.
604 END:VEVENT
606 """
607 value = self.params.value
608 if value is None:
609 _get_default_value = getattr(self, "_get_value", None)
610 if _get_default_value is not None:
611 value = _get_default_value()
612 return self.default_value if value is None else value
615def _set_value(self: VPROPERTY, value: str | None):
616 """Set the VALUE parameter."""
617 self.params.value = value
620def _del_value(self: VPROPERTY):
621 """Delete the VALUE parameter."""
622 del self.params.value
625VALUE = property(_get_value, _set_value, _del_value)
627LABEL = string_parameter(
628 "LABEL",
629 """LABEL provides a human-readable label.
631Conformance:
632 This property parameter is specified in :rfc:`7986`,
633 iCalendar Property Extensions.
635 :rfc:`9253` makes use of this for the LINK property.
636 This parameter maps to the "title"
637 attribute defined in Section 3.4.1 of :rfc:`8288`.
638 LABEL is used to label the destination
639 of a link such that it can be used as a human-readable identifier
640 (e.g., a menu entry) in the language indicated by the LANGUAGE
641 (if present). The LABEL MUST NOT
642 appear more than once in a given link; occurrences after the first
643 MUST be ignored by parsers.
645Description:
646 This property parameter MAY be specified on the
647 "CONFERENCE" property. It is anticipated that other extensions to
648 iCalendar will reuse this property parameter on new properties
649 that they define. As a result, clients MUST expect to find this
650 property parameter present on many different properties. It
651 provides a human-readable label that can be presented to calendar
652 users to allow them to discriminate between properties that might
653 be similar or provide additional information for properties that
654 are not self-describing. The "LANGUAGE" property parameter can be
655 used to specify the language of the text in the parameter value
656 (as per Section 3.2.10 of :rfc:`5545`).
658Examples:
659 This is a label of a chat.
661 .. code-block:: ics
663 CONFERENCE;VALUE=URI;FEATURE=VIDEO;
664 LABEL="Web video chat, access code=76543";
665 :https://video-chat.example.com/;group-id=1234
667""",
668)
670FMTTYPE = string_parameter(
671 "FMTTYPE",
672 """FMTTYPE specfies the content type of a referenced object.
674Conformance:
675 :rfc:`5545` specifies the FMTTYPE.
676 :rfc:`9253` adds FMTTYPE to LINK properties. In a LINK,
677 FMTTYPE maps to the "type"
678 attribute defined in Section 3.4.1 of :rfc:`8288`.
679 See :rfc:`6838`.
681Description:
682 This parameter can be specified on properties that are
683 used to reference an object. The parameter specifies the media
684 type :rfc:`4288` of the referenced object. For example, on the
685 "ATTACH" property, an FTP type URI value does not, by itself,
686 necessarily convey the type of content associated with the
687 resource. The parameter value MUST be the text for either an
688 IANA-registered media type or a non-standard media type.
690Example:
691 A Microsoft Word document:
693 .. code-block:: ics
695 ATTACH;FMTTYPE=application/msword:ftp://example.com/pub/docs/
696 agenda.doc
698 A website:
700 .. code-block:: ics
702 LINK;FMTTYPE=text/html;LINKREL=SOURCE;LABEL=Venue;VALUE=URI:
703 https://example.com/venue
705 """,
706)
708LINKREL = string_parameter(
709 "LINKREL",
710 """LINKREL
712Purpose:
713 LINKREL specifies the relationship of data referenced
714 by a LINK property.
716Conformance:
717 LINKREL is specified in :rfc:`9253`.
718 This parameter maps to the link relation type defined in
719 Section 2.1 of :rfc:`8288`.
720 It is always quoted.
722Description:
723 This parameter MUST be specified on all LINK properties and define
724 the type of reference.
725 This allows programs consuming this data to automatically scan
726 for references they support.
727 There is no default relation type. Any link relation in the
728 link registry established by :rfc:`8288`, or new link relations,
729 may be used.
730 It is expected that link relation types seeing significant usage
731 in calendaring will have the calendaring usage described in an RFC.
733 In the simplest case, a link relation type identifies the semantics
734 of a link. For example, a link with the relation type "copyright"
735 indicates that the current link context has a copyright resource at
736 the link target.
738 Link relation types can also be used to indicate that the target
739 resource has particular attributes, or exhibits particular
740 behaviours; for example, a "service" link implies that the link
741 target can be used as part of a defined protocol (in this case, a
742 service description).
744Registration:
745 There are two kinds of relation types: registered and extension.
746 These relation types are registered in :rfc:`8288`.
748.. seealso::
750 `Registered Link Relation Types
751 <https://www.iana.org/assignments/link-relations/link-relations.xhtml>`_.
754Examples:
755 This identifies the latest version of the event information.
757 .. code-block:: ics
759 LINKREL=latest-version
761""",
762)
765def _get_GAP(prop) -> timedelta | None: # noqa: N802
766 """GAP
768 Purpose:
769 GAP specifies the length of the gap, positive or negative,
770 between two components with a temporal relationship.
772 Format Definition:
773 Same as the DURATION value type defined in :rfc:`5545`, Section 3.3.6.
775 Description:
776 This parameter MAY be specified on the RELATED-TO property and defines
777 the duration of time between the predecessor and successor in an interval.
778 When positive, it defines the lag time between a task and its logical successor.
779 When negative, it defines the lead time.
781 Examples:
782 An example of lag time might be if Task-A is "paint the room" and Task-B is
783 "lay the carpets". Then, Task-A may be related to Task-B with
784 RELTYPE=FINISHTOSTART with a gap of 1 day -- long enough for the paint to dry.
786 .. code-block:: text
788 ====================
789 | paint the room |--+
790 ==================== |
791 |(lag of one day)
792 |
793 | ===================
794 +->| lay the carpet |
795 ===================
797 For an example of lead time, in constructing a two-story building,
798 the electrical work must be done before painting. However,
799 the painter can move in to the first floor as the electricians move upstairs.
801 .. code-block:: text
803 =====================
804 | electrical work |--+
805 ===================== |
806 +-------------+
807 |(lead of estimated time)
808 | ==================
809 +->| painting |
810 ==================
811 """
812 value = prop.params.get("GAP")
813 if value is None:
814 return None
815 from icalendar.prop import vDuration
817 if isinstance(value, str):
818 return vDuration.from_ical(value)
819 if not isinstance(value, vDuration):
820 raise TypeError("Value MUST be a vDuration instance")
821 return value.td
824def _set_GAP(prop, value: timedelta | str | None): # noqa: N802
825 """Set the GAP parameter as a timedelta."""
826 if value is None:
827 prop.params.pop("GAP", None)
828 return
829 from icalendar.prop import vDuration
831 prop.params["GAP"] = vDuration(value)
834def _del_GAP(prop): # noqa: N802
835 """Delete the GAP parameter."""
836 prop.params.pop("GAP", None)
839GAP = property(_get_GAP, _set_GAP, _del_GAP)
841__all__ = [
842 "ALTREP",
843 "CN",
844 "CUTYPE",
845 "DELEGATED_FROM",
846 "DELEGATED_TO",
847 "DIR",
848 "EMAIL",
849 "FBTYPE",
850 "FMTTYPE",
851 "GAP",
852 "LABEL",
853 "LANGUAGE",
854 "LINKREL",
855 "MEMBER",
856 "PARTSTAT",
857 "RANGE",
858 "RELATED",
859 "ROLE",
860 "RSVP",
861 "SENT_BY",
862 "TZID",
863 "VALUE",
864 "quoted_list_parameter",
865 "string_parameter",
866]