
    i$H                    `   d Z ddlmZ ddlZddlmZmZmZ ddlmZm	Z	 ddl
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ ddl0m1Z1 ddl2m3Z3 er"dd	l4m5Z5 dd
l6m7Z7 ddl8m9Z9m:Z:m;Z; ddl<m=Z= ddl>m?Z?  G d de1          Z@dgZAdS )z:rfc:`5545` VEVENT component.    )annotationsN)datedatetime	timedelta)TYPE_CHECKINGLiteral)%CONCEPTS_TYPE_SETTERLINKS_TYPE_SETTERRELATED_TO_TYPE_SETTERX_MOZ_LASTACK_propertyX_MOZ_SNOOZE_TIME_propertyattendees_propertycategories_propertyclass_propertycolor_propertyconferences_propertycontacts_propertycreate_single_propertydescription_propertyexdates_propertyget_duration_propertyget_end_property&get_start_end_duration_with_validationget_start_propertyimages_propertylocation_propertyorganizer_propertypriority_propertyproperty_del_durationproperty_doc_duration_templateproperty_get_durationproperty_set_durationrdates_propertyrrules_propertysequence_propertyset_duration_with_lockingset_end_with_lockingset_start_with_lockingstatus_propertysummary_propertytransparency_propertyuid_propertyurl_property)	Component)get_example)SequenceAlarms)CLASSSTATUSTRANSP)vCalAddress)
Conferencec                  t    e Zd ZdZdZdZdZdZdZdZ	dZ
edYd            ZedZd[d            Z eddeefed          Z eddeefed          Zd Z eeee ej        d                    Zed\d            Zej        d]d            Zed^d            Zej        d_d            Zed^d             Zej        d`d"            Z	 dadbd'Z	 dcddd*Z 	 daded,Z!e"Z#e$Z%e&Z'e(Z)e*Z+e,Z-e.Z/e0Z1e2Z3e4Z5e6Z7e8Z9e:Z;e<Z=e>Z?e@ZAeBZCeDZEeFZGeHZIeJZKeLZMd-d.lNmOZO e	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dfdg fdX            ZP xZQS )hEventab  A grouping of component properties that describe an event.

    Description:
        A "VEVENT" calendar component is a grouping of
        component properties, possibly including "VALARM" calendar
        components, that represents a scheduled amount of time on a
        calendar.  For example, it can be an activity; such as a one-hour
        long, department meeting from 8:00 AM to 9:00 AM, tomorrow.
        Generally, an event will take up time on an individual calendar.
        Hence, the event will appear as an opaque interval in a search for
        busy time.  Alternately, the event can have its Time Transparency
        set to "TRANSPARENT" in order to prevent blocking of the event in
        searches for busy time.

        The "VEVENT" is also the calendar component used to specify an
        anniversary or daily reminder within a calendar.  These events
        have a DATE value type for the "DTSTART" property instead of the
        default value type of DATE-TIME.  If such a "VEVENT" has a "DTEND"
        property, it MUST be specified as a DATE value also.  The
        anniversary type of "VEVENT" can span more than one date (i.e.,
        "DTEND" property value is set to a calendar date after the
        "DTSTART" property value).  If such a "VEVENT" has a "DURATION"
        property, it MUST be specified as a "dur-day" or "dur-week" value.

        The "DTSTART" property for a "VEVENT" specifies the inclusive
        start of the event.  For recurring events, it also specifies the
        very first instance in the recurrence set.  The "DTEND" property
        for a "VEVENT" calendar component specifies the non-inclusive end
        of the event.  For cases where a "VEVENT" calendar component
        specifies a "DTSTART" property with a DATE value type but no
        "DTEND" nor "DURATION" property, the event's duration is taken to
        be one day.  For cases where a "VEVENT" calendar component
        specifies a "DTSTART" property with a DATE-TIME value type but no
        "DTEND" property, the event ends on the same calendar date and
        time of day specified by the "DTSTART" property.

        The "VEVENT" calendar component cannot be nested within another
        calendar component.  However, "VEVENT" calendar components can be
        related to each other or to a "VTODO" or to a "VJOURNAL" calendar
        component with the "RELATED-TO" property.

    Examples:
        The following is an example of the "VEVENT" calendar
        component used to represent a meeting that will also be opaque to
        searches for busy time:

        .. code-block:: ics

            BEGIN:VEVENT
            UID:19970901T130000Z-123401@example.com
            DTSTAMP:19970901T130000Z
            DTSTART:19970903T163000Z
            DTEND:19970903T190000Z
            SUMMARY:Annual Employee Review
            CLASS:PRIVATE
            CATEGORIES:BUSINESS,HUMAN RESOURCES
            END:VEVENT

        The following is an example of the "VEVENT" calendar component
        used to represent a reminder that will not be opaque, but rather
        transparent, to searches for busy time:

        .. code-block:: ics

            BEGIN:VEVENT
            UID:19970901T130000Z-123402@example.com
            DTSTAMP:19970901T130000Z
            DTSTART:19970401T163000Z
            DTEND:19970402T010000Z
            SUMMARY:Laurel is in sensitivity awareness class.
            CLASS:PUBLIC
            CATEGORIES:BUSINESS,HUMAN RESOURCES
            TRANSP:TRANSPARENT
            END:VEVENT

        The following is an example of the "VEVENT" calendar component
        used to represent an anniversary that will occur annually:

        .. code-block:: ics

            BEGIN:VEVENT
            UID:19970901T130000Z-123403@example.com
            DTSTAMP:19970901T130000Z
            DTSTART;VALUE=DATE:19971102
            SUMMARY:Our Blissful Anniversary
            TRANSP:TRANSPARENT
            CLASS:CONFIDENTIAL
            CATEGORIES:ANNIVERSARY,PERSONAL,SPECIAL OCCASION
            RRULE:FREQ=YEARLY
            END:VEVENT

        The following is an example of the "VEVENT" calendar component
        used to represent a multi-day event scheduled from June 28th, 2007
        to July 8th, 2007 inclusively.  Note that the "DTEND" property is
        set to July 9th, 2007, since the "DTEND" property specifies the
        non-inclusive end of the event.

        .. code-block:: ics

            BEGIN:VEVENT
            UID:20070423T123432Z-541111@example.com
            DTSTAMP:20070423T123432Z
            DTSTART;VALUE=DATE:20070628
            DTEND;VALUE=DATE:20070709
            SUMMARY:Festival International de Jazz de Montreal
            TRANSP:TRANSPARENT
            END:VEVENT

        Create a new Event:

        .. code-block:: python

            >>> from icalendar import Event
            >>> from datetime import datetime
            >>> event = Event.new(start=datetime(2021, 1, 1, 12, 30, 0))
            >>> print(event.to_ical())
            BEGIN:VEVENT
            DTSTART:20210101T123000
            DTSTAMP:20250517T080612Z
            UID:d755cef5-2311-46ed-a0e1-6733c9e15c63
            END:VEVENT

    VEVENT)SUMMARYDTSTARTDTENDDURATIONDTSTAMPUIDRECURRENCE-IDSEQUENCERRULERDATEEXDATE)r@   r?   )r3   CREATEDCOLORDESCRIPTIONr<   GEOzLAST-MODIFIEDLOCATION	ORGANIZERPRIORITYr?   rB   r4   r;   r5   URLrA   r=   r>   r@   )r=   r>   )ATTACHATTENDEE
CATEGORIESCOMMENTCONTACTrE   RSTATUSRELATED	RESOURCESrD   rC   Treturnr2   c                $    ddl m}  ||           S )aQ  Compute the alarm times for this component.

        >>> from icalendar import Event
        >>> event = Event.example("rfc_9074_example_1")
        >>> len(event.alarms.times)
        1
        >>> alarm_time = event.alarms.times[0]
        >>> alarm_time.trigger  # The time when the alarm pops up
        datetime.datetime(2021, 3, 2, 10, 15, tzinfo=ZoneInfo(key='America/New_York'))
        >>> alarm_time.is_active()  # This alarm has not been acknowledged
        True

        Note that this only uses DTSTART and DTEND, but ignores
        RDATE, EXDATE, and RRULE properties.
        r   r1   )icalendar.alarmsr2   )selfr2   s     N/root/projects/butler/venv/lib/python3.11/site-packages/icalendar/cal/event.pyalarmszEvent.alarms   s$    " 	,+++++vd||    rfc_9074_example_3namestrc                H    |                      t          d|                    S )z0Return the calendar example with the given name.events)	from_icalr/   )clsr^   s     rZ   examplezEvent.example  s      }}[488999r\   r<   dtzQThe "DTSTART" property for a "VEVENT" specifies the inclusive start of the event.r=   zdThe "DTEND" property for a "VEVENT" calendar component specifies the non-inclusive end of the event.c                &    t          | ddd          S )z=Verify the calendar validity and return the right attributes.r<   r=   r:   )r   rY   s    rZ   _get_start_end_durationzEvent._get_start_end_duration  s    5)Wh
 
 	
r\   )	componentr   c                     t          |           S )a/  The duration of the VEVENT.

        Returns the DURATION property if set, otherwise calculated from start and end.
        When setting duration, the end time is automatically calculated from start +
        duration.

        You can set the duration to automatically adjust the end time while keeping
        start locked.

        Setting the duration will:

        1.  Keep the start time locked (unchanged)
        2.  Adjust the end time to start + duration
        3.  Remove any existing DTEND property
        4.  Set the DURATION property
        )r   rg   s    rZ   durationzEvent.duration,  s    $ %T***r\   valuec                    t          |t                    s%t          dt          |          j         d          |                     |d           d S )NzUse timedelta, not .start)locked)
isinstancer   	TypeErrortype__name__set_duration)rY   rl   s     rZ   rk   zEvent.duration@  sY    %++ 	KI$u++2FIIIJJJ 	%00000r\   date | datetimec                     t          |           S )a  The start of the event.

        Invalid values raise an InvalidCalendar.
        If there is no start, we also raise an IncompleteComponent error.

        You can get the start, end and duration of an event as follows:

        >>> from datetime import datetime
        >>> from icalendar import Event
        >>> event = Event()
        >>> event.start = datetime(2021, 1, 1, 12)
        >>> event.end = datetime(2021, 1, 1, 12, 30) # 30 minutes
        >>> event.duration  # 1800 seconds == 30 minutes
        datetime.timedelta(seconds=1800)
        >>> print(event.to_ical())
        BEGIN:VEVENT
        DTSTART:20210101T120000
        DTEND:20210101T123000
        END:VEVENT
        )r   rg   s    rZ   ro   zEvent.startH  s    , "$'''r\   ro   date | datetime | Nonec                    || _         dS )zSet the start.N)r<   )rY   ro   s     rZ   ro   zEvent.start`  s     r\   c                "    t          | d          S )zThe end of the event.

        Invalid values raise an InvalidCalendar error.
        If there is no end, we also raise an IncompleteComponent error.
        r=   )r   rg   s    rZ   endz	Event.ende  s      g...r\   r{   c                    || _         dS )zSet the end.N)r=   )rY   r{   s     rZ   r{   z	Event.endn  s     


r\   rk   timedelta | Nonerp   Literal['start', 'end']c                *    t          | ||d           dS )zSet the duration of the event relative to either start or end.

        Parameters:
            duration: The duration to set, or None to convert to DURATION property
            locked: Which property to keep unchanged ('start' or 'end')
        r=   N)r&   )rY   rk   rp   s      rZ   ru   zEvent.set_durations  s     	"$&'BBBBBr\   N!Literal['duration', 'end'] | Nonec                *    t          | ||d           dS )zSet the start and keep the duration or end of the event.

        Parameters:
            start: The start time to set
            locked: Which property to keep unchanged ('duration', 'end', or None
                for auto-detect)
        r=   N)r(   )rY   ro   rp   s      rZ   	set_startzEvent.set_start~  s     	tUFG<<<<<r\   Literal['start', 'duration']c                *    t          | ||d           dS )zSet the end of the component, keeping either the start or the duration same.

        Parameters:
            end: The end time to set
            locked: Which property to keep unchanged ('start' or 'duration')
        r=   N)r'   )rY   r{   rp   s      rZ   set_endzEvent.set_end  s     	T388888r\   r   )RECURRENCE_ID 	attendeeslist[vCalAddress] | None
categoriesSequence[str]classificationCLASS | Nonecolor
str | Nonecommentslist[str] | str | Noneconceptsr	   conferenceslist[Conference] | Nonecontactscreateddate | Nonedescriptionlast_modifiedlinksr
   location	organizervCalAddress | str | Nonepriority
int | Nonerecurrence_idrefids
related_tor   sequencestampstatusSTATUS | NonetransparencyTRANSP | Nonesummaryuidstr | uuid.UUID | Noneurlc          
        t                                          ||n|                                 |	||||||          }||_        |
|_        ||nt          j                    |_        ||_        ||_	        ||_
        ||_        ||_        ||_        ||_        ||_        ||_        ||_        ||_        ||_        ||_        ||_        ||_        ||_        | j        r|                     ||           |S )ao  Create a new event with all required properties.

        This creates a new Event in accordance with :rfc:`5545`.

        Parameters:
            attendees: The :attr:`attendees` of the event.
            categories: The :attr:`categories` of the event.
            classification: The :attr:`classification` of the event.
            color: The :attr:`color` of the event.
            comments: The :attr:`~icalendar.Component.comments` of the event.
            concepts: The :attr:`~icalendar.Component.concepts` of the event.
            conferences: The :attr:`conferences` of the event.
            created: The :attr:`~icalendar.Component.created` of the event.
            description: The :attr:`description` of the event.
            end: The :attr:`end` of the event.
            last_modified: The :attr:`~icalendar.Component.last_modified` of the event.
            links: The :attr:`~icalendar.Component.links` of the event.
            location: The :attr:`location` of the event.
            organizer: The :attr:`organizer` of the event.
            priority: The :attr:`priority` of the event.
            recurrence_id: The :attr:`RECURRENCE_ID` of the event.
            refids: :attr:`~icalendar.Component.refids` of the event.
            related_to: :attr:`~icalendar.Component.related_to` of the event.
            sequence: The :attr:`sequence` of the event.
            stamp: The :attr:`~icalendar.Component.stamp` of the event.
                If None, this is set to the current time.
            start: The :attr:`start` of the event.
            status: The :attr:`status` of the event.
            summary: The :attr:`summary` of the event.
            transparency: The :attr:`transparency` of the event.
            uid: The :attr:`uid` of the event.
                If None, this is set to a new :func:`uuid.uuid4`.
            url: The :attr:`url` of the event.

        Returns:
            :class:`Event`

        Raises:
            ~error.InvalidCalendar: If the content is not valid
                according to :rfc:`5545`.

        .. warning:: As time progresses, we will be stricter with the validation.
        N)r   r   r   r   r   r   r   r   )supernew_utc_nowr   r   uuiduuid4r   ro   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   _validate_new_validate_start_and_end)rc   r   r   r   r   r   r   r   r   r   r   r{   r   r   r   r   r   r   r   r   r   r   ro   r   r   r   r   r   event	__class__s                                rZ   r   z	Event.new  s   V ww{{ ,%%#,,..'! # 	
 	
  '?CC
		%!-	#!!)!#'+ 	4''s333r\   )rV   r2   )r]   )r^   r_   rV   r9   )rV   r   )rl   r   )rV   rv   )ro   rx   )r{   rx   )ro   )rk   r}   rp   r~   )N)ro   rv   rp   r   )r{   rv   rp   r   )Nr   NNNNNNNNNNNNNNNNNNNNNNNNN)6r   r   r   r   r   r   r   r   r   r   r   r	   r   r   r   r   r   r   r   r   r{   rx   r   r   r   r
   r   r   r   r   r   r   r   rx   r   r   r   r   r   r   r   r   ro   rx   r   r   r   r   r   r   r   r   r   r   )Rrt   
__module____qualname____doc__r^   canonical_orderrequired
singletons	exclusivemultipleignore_exceptionspropertyr[   classmethodrd   r   r   r   r<   r=   rh   r!   r"   r   r    formatr>   rk   setterro   r{   ru   r   r   r   X_MOZ_SNOOZE_TIMEr   X_MOZ_LASTACKr   r   r%   r   r   r   r#   rdatesr   exdatesr$   rrulesr,   r   r*   r   r   r   r   r   r-   r   r   r   r   r   r   r   r   r   r+   r   r)   r   r   r   r   imagesr   r   icalendar.attrr   r   __classcell__)r   s   @rZ   r9   r9   <   si       z zx DOHJ,IH    X( : : : : [: %$	4[ G #"	4n E
 
 
 x-&-AAA	 H + + + X+& _1 1 1 _1 ( ( ( X(. \   \ / / / X/ 	Z   Z
 MT	C 	C 	C 	C 	C SW
= 
= 
= 
= 
= LS	9 	9 	9 	9 	9 3*ME H$JFGF
CG&K#N
C"I H H H(LF"IF&K,,,,,, /3$&'+ +/)-/3+/#"&&*%)#'#.2#04)--1#!(, $&*"&*;j j j j j j [j j j j jr\   r9   )Br   
__future__r   r   r   r   r   typingr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   icalendar.cal.componentr.   icalendar.cal.examplesr/   collections.abcr0   rX   r2   icalendar.enumsr3   r4   r5   icalendar.propr6   icalendar.prop.conferencer7   r9   __all__r   r\   rZ   <module>r      s   # # " " " " " "  . . . . . . . . . . ) ) ) ) ) ) ) )& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &N . - - - - - . . . . . . 5((((((''''''5555555555******444444\ \ \ \ \I \ \ \~ )r\   