Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/icalendar/param.py: 52%

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

124 statements  

1"""Parameter access for icalendar. 

2 

3Related: 

4 

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""" 

10 

11from __future__ import annotations 

12 

13import functools 

14from typing import TYPE_CHECKING, TypeVar 

15 

16from icalendar import enums 

17 

18if TYPE_CHECKING: 

19 from collections.abc import Callable 

20 from datetime import timedelta 

21 from enum import Enum 

22 

23 

24if TYPE_CHECKING: 

25 from icalendar.prop import VPROPERTY 

26 

27 

28def _default_return_none() -> str | None: 

29 """Return None by default.""" 

30 return None 

31 

32 

33def _default_return_string() -> str: 

34 """Return None by default.""" 

35 return "" 

36 

37 

38T = TypeVar("T") 

39 

40 

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 """Return a parameter with a quoted value (case sensitive).""" 

49 

50 if convert_to is None: 

51 convert_to = convert 

52 

53 @functools.wraps(default) 

54 def fget(self: VPROPERTY) -> str | None: 

55 value = self.params.get(name) 

56 if value is None: 

57 return default() 

58 return convert(value) if convert else value 

59 

60 def fset(self: VPROPERTY, value: str | None): 

61 if value is None: 

62 fdel(self) 

63 else: 

64 self.params[name] = convert_to(value) if convert_to else value 

65 

66 def fdel(self: VPROPERTY): 

67 self.params.pop(name, None) 

68 

69 return property(fget, fset, fdel, doc=doc) 

70 

71 

72ALTREP = string_parameter( 

73 "ALTREP", 

74 """ALTREP - Specify an alternate text representation for the property value. 

75 

76Description: 

77 This parameter specifies a URI that points to an 

78 alternate representation for a textual property value. A property 

79 specifying this parameter MUST also include a value that reflects 

80 the default representation of the text value. The URI parameter 

81 value MUST be specified in a quoted-string. 

82 

83.. note:: 

84 

85 While there is no restriction imposed on the URI schemes 

86 allowed for this parameter, Content Identifier (CID) :rfc:`2392`, 

87 HTTP :rfc:`2616`, and HTTPS :rfc:`2818` are the URI schemes most 

88 commonly used by current implementations. 

89""", 

90) 

91 

92CN = string_parameter( 

93 "CN", 

94 """Specify the common name to be associated with the calendar user specified. 

95 

96Description: 

97 This parameter can be specified on properties with a 

98 CAL-ADDRESS value type. The parameter specifies the common name 

99 to be associated with the calendar user specified by the property. 

100 The parameter value is text. The parameter value can be used for 

101 display text to be associated with the calendar address specified 

102 by the property. 

103""", 

104 default=_default_return_string, 

105) 

106 

107 

108def _default_return_individual() -> enums.CUTYPE | str: 

109 """Default value.""" 

110 return enums.CUTYPE.INDIVIDUAL 

111 

112 

113def _convert_enum(enum: type[Enum]) -> Callable[[str], Enum]: 

114 def convert(value: str) -> str: 

115 """Convert if possible.""" 

116 try: 

117 return enum(value.upper()) 

118 except ValueError: 

119 return value 

120 

121 return convert 

122 

123 

124CUTYPE = string_parameter( 

125 "CUTYPE", 

126 """Identify the type of calendar user specified by the property. 

127 

128Description: 

129 This parameter can be specified on properties with a 

130 CAL-ADDRESS value type. The parameter identifies the type of 

131 calendar user specified by the property. If not specified on a 

132 property that allows this parameter, the default is INDIVIDUAL. 

133 Applications MUST treat x-name and iana-token values they don't 

134 recognize the same way as they would the UNKNOWN value. 

135""", 

136 default=_default_return_individual, 

137 convert=_convert_enum(enums.CUTYPE), 

138) 

139 

140 

141def quoted_list_parameter(name: str, doc: str) -> property: 

142 """Return a parameter that contains a quoted list.""" 

143 

144 def fget(self: VPROPERTY) -> tuple[str]: 

145 value = self.params.get(name) 

146 if value is None: 

147 return () 

148 if isinstance(value, str): 

149 return tuple(value.split(",")) 

150 return value 

151 

152 def fset(self: VPROPERTY, value: str | tuple[str]): 

153 if value == (): 

154 fdel(self) 

155 else: 

156 self.params[name] = (value,) if isinstance(value, str) else value 

157 

158 def fdel(self: VPROPERTY): 

159 self.params.pop(name, None) 

160 

161 return property(fget, fset, fdel, doc=doc) 

162 

163 

164DELEGATED_FROM = quoted_list_parameter( 

165 "DELEGATED-FROM", 

166 """Specify the calendar users that have delegated their participation to the calendar user specified by the property. 

167 

168Description: 

169 This parameter can be specified on properties with a 

170 CAL-ADDRESS value type. This parameter specifies those calendar 

171 users that have delegated their participation in a group-scheduled 

172 event or to-do to the calendar user specified by the property. 

173 The individual calendar address parameter values MUST each be 

174 specified in a quoted-string. 

175""", # noqa: E501 

176) 

177 

178DELEGATED_TO = quoted_list_parameter( 

179 "DELEGATED-TO", 

180 """Specify the calendar users to whom the calendar user specified by the property has delegated participation. 

181 

182Description: 

183 This parameter can be specified on properties with a 

184 CAL-ADDRESS value type. This parameter specifies those calendar 

185 users whom have been delegated participation in a group-scheduled 

186 event or to-do by the calendar user specified by the property. 

187 The individual calendar address parameter values MUST each be 

188 specified in a quoted-string. 

189 """, # noqa: E501 

190) 

191 

192DIR = string_parameter( 

193 "DIR", 

194 """Specify reference to a directory entry associated with the calendar user specified by the property. 

195 

196Description: 

197 This parameter can be specified on properties with a 

198 CAL-ADDRESS value type. The parameter specifies a reference to 

199 the directory entry associated with the calendar user specified by 

200 the property. The parameter value is a URI. The URI parameter 

201 value MUST be specified in a quoted-string. 

202 

203.. note:: 

204 

205 While there is no restriction imposed on the URI schemes 

206 allowed for this parameter, CID :rfc:`2392`, DATA :rfc:`2397`, FILE 

207 :rfc:`1738`, FTP :rfc:`1738`, HTTP :rfc:`2616`, HTTPS :rfc:`2818`, LDAP 

208 :rfc:`4516`, and MID :rfc:`2392` are the URI schemes most commonly 

209 used by current implementations. 

210""", # noqa: E501 

211) 

212 

213 

214def _default_return_busy() -> enums.FBTYPE | str: 

215 """Default value.""" 

216 return enums.FBTYPE.BUSY 

217 

218 

219FBTYPE = string_parameter( 

220 "FBTYPE", 

221 """Specify the free or busy time type. 

222 

223Description: 

224 This parameter specifies the free or busy time type. 

225 The value FREE indicates that the time interval is free for 

226 scheduling. The value BUSY indicates that the time interval is 

227 busy because one or more events have been scheduled for that 

228 interval. The value BUSY-UNAVAILABLE indicates that the time 

229 interval is busy and that the interval can not be scheduled. The 

230 value BUSY-TENTATIVE indicates that the time interval is busy 

231 because one or more events have been tentatively scheduled for 

232 that interval. If not specified on a property that allows this 

233 parameter, the default is BUSY. Applications MUST treat x-name 

234 and iana-token values they don't recognize the same way as they 

235 would the BUSY value. 

236""", 

237 default=_default_return_busy, 

238 convert=_convert_enum(enums.FBTYPE), 

239) 

240 

241LANGUAGE = string_parameter( 

242 "LANGUAGE", 

243 """Specify the language for text values in a property or property parameter. 

244 

245Description: 

246 This parameter identifies the language of the text in 

247 the property value and of all property parameter values of the 

248 property. The value of the "LANGUAGE" property parameter is that 

249 defined in :rfc:`5646`. 

250 

251 For transport in a MIME entity, the Content-Language header field 

252 can be used to set the default language for the entire body part. 

253 Otherwise, no default language is assumed. 

254""", 

255) 

256 

257MEMBER = quoted_list_parameter( 

258 "MEMBER", 

259 """Specify the group or list membership of the calendar user specified by the property. 

260 

261Description: 

262 This parameter can be specified on properties with a 

263 CAL-ADDRESS value type. The parameter identifies the groups or 

264 list membership for the calendar user specified by the property. 

265 The parameter value is either a single calendar address in a 

266 quoted-string or a COMMA-separated list of calendar addresses, 

267 each in a quoted-string. The individual calendar address 

268 parameter values MUST each be specified in a quoted-string. 

269""", # noqa: E501 

270) 

271 

272 

273def _default_return_needs_action() -> enums.PARTSTAT | str: 

274 """Default value.""" 

275 return enums.PARTSTAT.NEEDS_ACTION 

276 

277 

278PARTSTAT = string_parameter( 

279 "PARTSTAT", 

280 """Specify the participation status for the calendar user specified by the property. 

281 

282Description: 

283 This parameter can be specified on properties with a 

284 CAL-ADDRESS value type. The parameter identifies the 

285 participation status for the calendar user specified by the 

286 property value. The parameter values differ depending on whether 

287 they are associated with a group-scheduled "VEVENT", "VTODO", or 

288 "VJOURNAL". The values MUST match one of the values allowed for 

289 the given calendar component. If not specified on a property that 

290 allows this parameter, the default value is NEEDS-ACTION. 

291 Applications MUST treat x-name and iana-token values they don't 

292 recognize the same way as they would the NEEDS-ACTION value. 

293""", 

294 default=_default_return_needs_action, 

295 convert=_convert_enum(enums.PARTSTAT), 

296) 

297 

298 

299def _default_range_none() -> enums.RANGE | str | None: 

300 return None 

301 

302 

303RANGE = string_parameter( 

304 "RANGE", 

305 """Specify the effective range of recurrence instances from the instance specified by the recurrence identifier specified by the property. 

306 

307Description: 

308 This parameter can be specified on a property that 

309 specifies a recurrence identifier. The parameter specifies the 

310 effective range of recurrence instances that is specified by the 

311 property. The effective range is from the recurrence identifier 

312 specified by the property. If this parameter is not specified on 

313 an allowed property, then the default range is the single instance 

314 specified by the recurrence identifier value of the property. The 

315 parameter value can only be "THISANDFUTURE" to indicate a range 

316 defined by the recurrence identifier and all subsequent instances. 

317 The value "THISANDPRIOR" is deprecated by this revision of 

318 iCalendar and MUST NOT be generated by applications. 

319""", # noqa: E501 

320 default=_default_range_none, 

321 convert=_convert_enum(enums.RANGE), 

322) 

323 

324 

325def _default_related() -> enums.RELATED | str: 

326 return enums.RELATED.START 

327 

328 

329RELATED = string_parameter( 

330 "RELATED", 

331 """Specify the relationship of the alarm trigger with respect to the start or end of the calendar component. 

332 

333Description: 

334 This parameter can be specified on properties that 

335 specify an alarm trigger with a "DURATION" value type. The 

336 parameter specifies whether the alarm will trigger relative to the 

337 start or end of the calendar component. The parameter value START 

338 will set the alarm to trigger off the start of the calendar 

339 component; the parameter value END will set the alarm to trigger 

340 off the end of the calendar component. If the parameter is not 

341 specified on an allowable property, then the default is START. 

342 

343""", # noqa: E501 

344 default=_default_related, 

345 convert=_convert_enum(enums.RELATED), 

346) 

347 

348 

349def _default_req_participant() -> enums.ROLE | str: 

350 return enums.ROLE.REQ_PARTICIPANT 

351 

352 

353ROLE = string_parameter( 

354 "ROLE", 

355 """Specify the participation role for the calendar user specified by the property. 

356 

357Description: 

358 This parameter can be specified on properties with a 

359 CAL-ADDRESS value type. The parameter specifies the participation 

360 role for the calendar user specified by the property in the group 

361 schedule calendar component. If not specified on a property that 

362 allows this parameter, the default value is REQ-PARTICIPANT. 

363 Applications MUST treat x-name and iana-token values they don't 

364 recognize the same way as they would the REQ-PARTICIPANT value. 

365""", 

366 default=_default_req_participant, 

367 convert=_convert_enum(enums.ROLE), 

368) 

369 

370 

371def boolean_parameter(name: str, default: bool, doc: str) -> property: 

372 def _default() -> bool: 

373 return default 

374 

375 return string_parameter( 

376 name, 

377 doc, 

378 default=_default, 

379 convert=lambda x: x.upper() == "TRUE", 

380 convert_to=lambda x: "TRUE" if x else "FALSE", 

381 ) 

382 

383 

384RSVP = boolean_parameter( 

385 "RSVP", 

386 False, 

387 """Specify whether there is an expectation of a favor of anreply from the calendar user specified by the property value. 

388 

389Description: 

390 This parameter can be specified on properties with a 

391 CAL-ADDRESS value type. The parameter identifies the expectation 

392 of a reply from the calendar user specified by the property value. 

393 This parameter is used by the "Organizer" to request a 

394 participation status reply from an "Attendee" of a group-scheduled 

395 event or to-do. If not specified on a property that allows this 

396 parameter, the default value is ``False``. 

397""", # noqa: E501 

398) 

399 

400SENT_BY = string_parameter( 

401 "SENT-BY", 

402 """Specify the calendar user that is acting on behalf of the calendar user specified by the property. 

403 

404Description: 

405 This parameter can be specified on properties with a 

406 CAL-ADDRESS value type. The parameter specifies the calendar user 

407 that is acting on behalf of the calendar user specified by the 

408 property. The parameter value MUST be a mailto URI as defined in 

409 :rfc:`2368`. The individual calendar address parameter values MUST 

410 each be specified in a quoted-string. 

411""", # noqa: E501 

412) 

413 

414TZID = string_parameter( 

415 "TZID", 

416 """Specify the identifier for the time zone definition for a time component in the property value. 

417 

418Description: 

419 This parameter MUST be specified on the "DTSTART", 

420 "DTEND", "DUE", "EXDATE", and "RDATE" properties when either a 

421 DATE-TIME or TIME value type is specified and when the value is 

422 neither a UTC or a "floating" time. Refer to the DATE-TIME or 

423 TIME value type definition for a description of UTC and "floating 

424 time" formats. This property parameter specifies a text value 

425 that uniquely identifies the "VTIMEZONE" calendar component to be 

426 used when evaluating the time portion of the property. The value 

427 of the "TZID" property parameter will be equal to the value of the 

428 "TZID" property for the matching time zone definition. An 

429 individual "VTIMEZONE" calendar component MUST be specified for 

430 each unique "TZID" parameter value specified in the iCalendar 

431 object. 

432 

433 The parameter MUST be specified on properties with a DATE-TIME 

434 value if the DATE-TIME is not either a UTC or a "floating" time. 

435 Failure to include and follow VTIMEZONE definitions in iCalendar 

436 objects may lead to inconsistent understanding of the local time 

437 at any given location. 

438 

439 The presence of the SOLIDUS character as a prefix, indicates that 

440 this "TZID" represents a unique ID in a globally defined time zone 

441 registry (when such registry is defined). 

442 

443.. note:: 

444 

445 This document does not define a naming convention for 

446 time zone identifiers. Implementers may want to use the naming 

447 conventions defined in existing time zone specifications such 

448 as the public-domain TZ database (TZDB). The specification of 

449 globally unique time zone identifiers is not addressed by this 

450 document and is left for future study. 

451""", # noqa: E501 

452) 

453 

454 

455def _default_return_parent() -> enums.RELTYPE: 

456 return enums.RELTYPE.PARENT 

457 

458 

459RELTYPE = string_parameter( 

460 "RELTYPE", 

461 """Specify the type of hierarchical relationship associated with a component. 

462 

463Conformance: 

464 :rfc:`5545` introduces the RELTYPE property parameter. 

465 :rfc:`9253` adds new values. 

466 

467Description: 

468 This parameter can be specified on a property that 

469 references another related calendar. The parameter specifies the 

470 hierarchical relationship type of the calendar component 

471 referenced by the property. The parameter value can be PARENT, to 

472 indicate that the referenced calendar component is a superior of 

473 calendar component; CHILD to indicate that the referenced calendar 

474 component is a subordinate of the calendar component; or SIBLING 

475 to indicate that the referenced calendar component is a peer of 

476 the calendar component. If this parameter is not specified on an 

477 allowable property, the default relationship type is PARENT. 

478 Applications MUST treat x-name and iana-token values they don't 

479 recognize the same way as they would the PARENT value. 

480""", 

481 default=_default_return_parent, 

482 convert=_convert_enum(enums.RELTYPE), 

483) 

484 

485 

486def _get_value(self: VPROPERTY) -> str: 

487 """The VALUE parameter or the default. 

488 

489 Purpose: 

490 VALUE explicitly specify the value type format for a property value. 

491 

492 Description: 

493 This parameter specifies the value type and format of 

494 the property value. The property values MUST be of a single value 

495 type. For example, a "RDATE" property cannot have a combination 

496 of DATE-TIME and TIME value types. 

497 

498 If the property's value is the default value type, then this 

499 parameter need not be specified. However, if the property's 

500 default value type is overridden by some other allowable value 

501 type, then this parameter MUST be specified. 

502 

503 Applications MUST preserve the value data for ``x-name`` and 

504 ``iana-token`` values that they don't recognize without attempting 

505 to interpret or parse the value data. 

506 

507 Returns: 

508 The VALUE parameter or the default. 

509 

510 Examples: 

511 The VALUE defaults to the name of the property. 

512 Note that it is case-insensitive but always uppercase. 

513 

514 .. code-block:: pycon 

515 

516 >>> from icalendar import vBoolean 

517 >>> b = vBoolean(True) 

518 >>> b.VALUE 

519 'BOOLEAN' 

520 

521 Setting the VALUE parameter of a typed property usually does not make sense. 

522 For convenience, using this property, the value will be converted to 

523 an uppercase string. 

524 If you have some custom property, you might use it like this: 

525 

526 .. code-block:: pycon 

527 

528 >>> from icalendar import vUnknown, Event 

529 >>> v = vUnknown("Some property text.") 

530 >>> v.VALUE = "x-type" # lower case 

531 >>> v.VALUE 

532 'X-TYPE' 

533 >>> event = Event() 

534 >>> event.add("x-prop", v) 

535 >>> print(event.to_ical()) 

536 BEGIN:VEVENT 

537 X-PROP;VALUE=X-TYPE:Some property text. 

538 END:VEVENT 

539 

540 """ 

541 value = self.params.value 

542 if value is None: 

543 _get_default_value = getattr(self, "_get_value", None) 

544 if _get_default_value is not None: 

545 value = _get_default_value() 

546 return self.default_value if value is None else value 

547 

548 

549def _set_value(self: VPROPERTY, value: str | None): 

550 """Set the VALUE parameter.""" 

551 self.params.value = value 

552 

553 

554def _del_value(self: VPROPERTY): 

555 """Delete the VALUE parameter.""" 

556 del self.params.value 

557 

558 

559VALUE = property(_get_value, _set_value, _del_value) 

560 

561LABEL = string_parameter( 

562 "LABEL", 

563 """LABEL provides a human-readable label. 

564 

565Conformance: 

566 This property parameter is specified in :rfc:`7986`, 

567 iCalendar Property Extensions. 

568 

569 :rfc:`9253` makes use of this for the LINK property. 

570 This parameter maps to the "title" 

571 attribute defined in Section 3.4.1 of :rfc:`8288`. 

572 LABEL is used to label the destination 

573 of a link such that it can be used as a human-readable identifier 

574 (e.g., a menu entry) in the language indicated by the LANGUAGE 

575 (if present). The LABEL MUST NOT 

576 appear more than once in a given link; occurrences after the first 

577 MUST be ignored by parsers. 

578 

579Description: 

580 This property parameter MAY be specified on the 

581 "CONFERENCE" property. It is anticipated that other extensions to 

582 iCalendar will reuse this property parameter on new properties 

583 that they define. As a result, clients MUST expect to find this 

584 property parameter present on many different properties. It 

585 provides a human-readable label that can be presented to calendar 

586 users to allow them to discriminate between properties that might 

587 be similar or provide additional information for properties that 

588 are not self-describing. The "LANGUAGE" property parameter can be 

589 used to specify the language of the text in the parameter value 

590 (as per Section 3.2.10 of :rfc:`5545`). 

591 

592Examples: 

593 This is a label of a chat. 

594 

595 .. code-block:: text 

596 

597 CONFERENCE;VALUE=URI;FEATURE=VIDEO; 

598 LABEL="Web video chat, access code=76543"; 

599 :https://video-chat.example.com/;group-id=1234 

600 

601""", 

602) 

603 

604FMTTYPE = string_parameter( 

605 "FMTTYPE", 

606 """FMTTYPE specfies the content type of a referenced object. 

607 

608Conformance: 

609 :rfc:`5545` specifies the FMTTYPE. 

610 :rfc:`9253` adds FMTTYPE to LINK properties. In a LINK, 

611 FMTTYPE maps to the "type" 

612 attribute defined in Section 3.4.1 of :rfc:`8288`. 

613 See :rfc:`6838`. 

614 

615Description: 

616 This parameter can be specified on properties that are 

617 used to reference an object. The parameter specifies the media 

618 type :rfc:`4288` of the referenced object. For example, on the 

619 "ATTACH" property, an FTP type URI value does not, by itself, 

620 necessarily convey the type of content associated with the 

621 resource. The parameter value MUST be the text for either an 

622 IANA-registered media type or a non-standard media type. 

623 

624Example: 

625 A Microsoft Word document: 

626 

627 .. code-block:: text 

628 

629 ATTACH;FMTTYPE=application/msword:ftp://example.com/pub/docs/ 

630 agenda.doc 

631 

632 A website: 

633 

634 .. code-block:: text 

635 

636 LINK;FMTTYPE=text/html;LINKREL=SOURCE;LABEL=Venue;VALUE=URI: 

637 https://example.com/venue 

638 

639 """, 

640) 

641 

642LINKREL = string_parameter( 

643 "LINKREL", 

644 """LINKREL 

645 

646Purpose: 

647 LINKREL specifies the relationship of data referenced 

648 by a LINK property. 

649 

650Conformance: 

651 LINKREL is specified in :rfc:`9253`. 

652 This parameter maps to the link relation type defined in 

653 Section 2.1 of :rfc:`8288`. 

654 It is always quoted. 

655 

656Description: 

657 This parameter MUST be specified on all LINK properties and define 

658 the type of reference. 

659 This allows programs consuming this data to automatically scan 

660 for references they support. 

661 There is no default relation type. Any link relation in the 

662 link registry established by :rfc:`8288`, or new link relations, 

663 may be used. 

664 It is expected that link relation types seeing significant usage 

665 in calendaring will have the calendaring usage described in an RFC. 

666 

667 In the simplest case, a link relation type identifies the semantics 

668 of a link. For example, a link with the relation type "copyright" 

669 indicates that the current link context has a copyright resource at 

670 the link target. 

671 

672 Link relation types can also be used to indicate that the target 

673 resource has particular attributes, or exhibits particular 

674 behaviours; for example, a "service" link implies that the link 

675 target can be used as part of a defined protocol (in this case, a 

676 service description). 

677 

678Registration: 

679 There are two kinds of relation types: registered and extension. 

680 These relation types are registered in :rfc:`8288`. 

681 

682.. seealso:: 

683 

684 `Registered Link Relation Types 

685 <https://www.iana.org/assignments/link-relations/link-relations.xhtml>`_. 

686 

687 

688Examples: 

689 This identifies the latest version of the event information. 

690 

691 .. code-block:: text 

692 

693 LINKREL=latest-version 

694 

695""", 

696) 

697 

698 

699def _get_GAP(prop) -> timedelta | None: # noqa: N802 

700 """GAP 

701 

702 Purpose: 

703 GAP specifies the length of the gap, positive or negative, 

704 between two components with a temporal relationship. 

705 

706 Format Definition: 

707 Same as the DURATION value type defined in :rfc:`5545`, Section 3.3.6. 

708 

709 Description: 

710 This parameter MAY be specified on the RELATED-TO property and defines 

711 the duration of time between the predecessor and successor in an interval. 

712 When positive, it defines the lag time between a task and its logical successor. 

713 When negative, it defines the lead time. 

714 

715 Examples: 

716 An example of lag time might be if Task-A is "paint the room" and Task-B is 

717 "lay the carpets". Then, Task-A may be related to Task-B with 

718 RELTYPE=FINISHTOSTART with a gap of 1 day -- long enough for the paint to dry. 

719 

720 .. code-block:: text 

721 

722 ==================== 

723 | paint the room |--+ 

724 ==================== | 

725 |(lag of one day) 

726 | 

727 | =================== 

728 +->| lay the carpet | 

729 =================== 

730 

731 For an example of lead time, in constructing a two-story building, 

732 the electrical work must be done before painting. However, 

733 the painter can move in to the first floor as the electricians move upstairs. 

734 

735 .. code-block:: text 

736 

737 ===================== 

738 | electrical work |--+ 

739 ===================== | 

740 +-------------+ 

741 |(lead of estimated time) 

742 | ================== 

743 +->| painting | 

744 ================== 

745 """ 

746 value = prop.params.get("GAP") 

747 if value is None: 

748 return None 

749 from icalendar.prop import vDuration 

750 

751 if isinstance(value, str): 

752 return vDuration.from_ical(value) 

753 if not isinstance(value, vDuration): 

754 raise TypeError("Value MUST be a vDuration instance") 

755 return value.td 

756 

757 

758def _set_GAP(prop, value: timedelta | str | None): # noqa: N802 

759 """Set the GAP parameter as a timedelta.""" 

760 if value is None: 

761 prop.params.pop("GAP", None) 

762 return 

763 from icalendar.prop import vDuration 

764 

765 prop.params["GAP"] = vDuration(value) 

766 

767 

768def _del_GAP(prop): # noqa: N802 

769 """Delete the GAP parameter.""" 

770 prop.params.pop("GAP", None) 

771 

772 

773GAP = property(_get_GAP, _set_GAP, _del_GAP) 

774 

775__all__ = [ 

776 "ALTREP", 

777 "CN", 

778 "CUTYPE", 

779 "DELEGATED_FROM", 

780 "DELEGATED_TO", 

781 "DIR", 

782 "FBTYPE", 

783 "FMTTYPE", 

784 "GAP", 

785 "LABEL", 

786 "LANGUAGE", 

787 "LINKREL", 

788 "MEMBER", 

789 "PARTSTAT", 

790 "RANGE", 

791 "RELATED", 

792 "ROLE", 

793 "RSVP", 

794 "SENT_BY", 

795 "TZID", 

796 "VALUE", 

797 "quoted_list_parameter", 

798 "string_parameter", 

799]