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

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

23 statements  

1"""UID values from :rfc:`9253`.""" 

2 

3 

4import uuid 

5from typing import ClassVar 

6 

7from icalendar.compatibility import Self 

8 

9from .text import vText 

10 

11 

12class vUid(vText): 

13 """A UID of a component. 

14 

15 This is defined in :rfc:`9253`, Section 7. 

16 """ 

17 

18 default_value: ClassVar[str] = "UID" 

19 

20 @classmethod 

21 def new(cls) -> Self: 

22 """Create a new UID for convenience. 

23 

24 .. code-block:: pycon 

25 

26 >>> from icalendar import vUid 

27 >>> vUid.new() 

28 vUid('d755cef5-2311-46ed-a0e1-6733c9e15c63') 

29 

30 """ 

31 return vUid(uuid.uuid4()) 

32 

33 @property 

34 def uid(self) -> str: 

35 """The UID of this property.""" 

36 return str(self) 

37 

38 @property 

39 def ical_value(self) -> str: 

40 """The UID of this property.""" 

41 return self.uid 

42 

43 def __repr__(self) -> str: 

44 """repr(self)""" 

45 return f"{self.__class__.__name__}({self.uid!r})" 

46 

47 from icalendar.param import FMTTYPE, LABEL, LINKREL 

48 

49 @classmethod 

50 def examples(cls) -> list[Self]: 

51 """Examples of vUid.""" 

52 return [cls("d755cef5-2311-46ed-a0e1-6733c9e15c63")] 

53 

54__all__ = ["vUid"]