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 

3import uuid 

4from typing import ClassVar 

5 

6from icalendar.compatibility import Self 

7 

8from .text import vText 

9 

10 

11class vUid(vText): 

12 """A UID of a component. 

13 

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

15 """ 

16 

17 default_value: ClassVar[str] = "UID" 

18 

19 @classmethod 

20 def new(cls) -> Self: 

21 """Create a new UID for convenience. 

22 

23 .. code-block:: pycon 

24 

25 >>> from icalendar import vUid 

26 >>> vUid.new() 

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

28 

29 """ 

30 return vUid(uuid.uuid4()) 

31 

32 @property 

33 def uid(self) -> str: 

34 """The UID of this property.""" 

35 return str(self) 

36 

37 @property 

38 def ical_value(self) -> str: 

39 """The UID of this property.""" 

40 return self.uid 

41 

42 def __repr__(self) -> str: 

43 """repr(self)""" 

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

45 

46 from icalendar.param import FMTTYPE, LABEL, LINKREL 

47 

48 @classmethod 

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

50 """Examples of vUid.""" 

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

52 

53 

54__all__ = ["vUid"]