Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/icalendar/prop/conference.py: 56%

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

25 statements  

1"""Conferences according to Section 5.11 of :rfc:`7986`.""" 

2 

3from __future__ import annotations 

4 

5from dataclasses import dataclass 

6 

7from icalendar.prop import vUri 

8 

9 

10@dataclass 

11class Conference: 

12 """Conferences according to Section 5.11 of :rfc:`7986`. 

13 

14 Purpose: 

15 Information for accessing a conferencing system. 

16 

17 Conformance: 

18 This property can be specified multiple times in a 

19 "VEVENT" or "VTODO" calendar component. 

20 

21 Description: 

22 This property specifies information for accessing a 

23 conferencing system for attendees of a meeting or task. This 

24 might be for a telephone-based conference number dial-in with 

25 access codes included (such as a tel: URI :rfc:`3966` or a sip: or 

26 sips: URI :rfc:`3261`), for a web-based video chat (such as an http: 

27 or https: URI :rfc:`7230`), or for an instant messaging group chat 

28 room (such as an xmpp: URI :rfc:`5122`). If a specific URI for a 

29 conferencing system is not available, a data: URI :rfc:`2397` 

30 containing a text description can be used. 

31 

32 A conference system can be a bidirectional communication channel 

33 or a uni-directional "broadcast feed". 

34 

35 The "FEATURE" property parameter is used to describe the key 

36 capabilities of the conference system to allow a client to choose 

37 the ones that give the required level of interaction from a set of 

38 multiple properties. 

39 

40 The "LABEL" property parameter is used to convey additional 

41 details on the use of the URI. For example, the URIs or access 

42 codes for the moderator and attendee of a teleconference system 

43 could be different, and the "LABEL" property parameter could be 

44 used to "tag" each "CONFERENCE" property to indicate which is 

45 which. 

46 

47 The "LANGUAGE" property parameter can be used to specify the 

48 language used for text values used with this property (as per 

49 Section 3.2.10 of :rfc:`5545`). 

50 

51 Example: 

52 The following are examples of this property: 

53 

54 .. code-block:: text 

55 

56 CONFERENCE;VALUE=URI;FEATURE=PHONE,MODERATOR; 

57 LABEL=Moderator dial-in:tel:+1-412-555-0123,,,654321 

58 CONFERENCE;VALUE=URI;FEATURE=PHONE; 

59 LABEL=Attendee dial-in:tel:+1-412-555-0123,,,555123 

60 CONFERENCE;VALUE=URI;FEATURE=PHONE; 

61 LABEL=Attendee dial-in:tel:+1-888-555-0456,,,555123 

62 CONFERENCE;VALUE=URI;FEATURE=CHAT; 

63 LABEL=Chat room:xmpp:chat-123@conference.example.com 

64 CONFERENCE;VALUE=URI;FEATURE=AUDIO,VIDEO; 

65 LABEL=Attendee dial-in:https://chat.example.com/audio?id=123456 

66 """ 

67 

68 # see https://stackoverflow.com/a/18348004/1320237 

69 uri: str 

70 feature: list[str] | str | None = None 

71 label: list[str] | str | None = None 

72 language: list[str] | str | None = None 

73 

74 @classmethod 

75 def from_uri(cls, uri: vUri | str): 

76 """Create a Conference from a URI.""" 

77 if isinstance(uri, str) and not isinstance(uri, vUri): 

78 uri = vUri(uri) 

79 return cls( 

80 uri, 

81 feature=uri.params.get("feature"), 

82 label=uri.params.get("label"), 

83 language=uri.params.get("language"), 

84 ) 

85 

86 def to_uri(self) -> vUri: 

87 """Convert the Conference to a vUri.""" 

88 params = {} 

89 if self.feature: 

90 params["FEATURE"] = self.feature 

91 if self.label: 

92 params["LABEL"] = self.label 

93 if self.language: 

94 params["LANGUAGE"] = self.language 

95 return vUri(self.uri, params=params) 

96 

97 

98__all__ = ["Conference"]