
    }f@                         d dl 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 d dlmZ ddlmZ ddlmZmZ ddlmZ d d	lmZ dd
lmZ ddlmZmZ d dlmZ d dlmZ  G d de      Z  G d de      Z!y)    N)datetime	timedelta)DictIterableList
NamedTupleOptionalSetTupleUnion)Arrow   )	BaseAlarm)Attendee	Organizer)	Component)	Container)	ArrowLike)	get_arrowuid_gen)EventParser)EventSerializerc                   "    e Zd ZU eed<   eed<   y)Geolatitude	longitudeN)__name__
__module____qualname__float__annotations__     H/var/www/feuerwehr-webapp/venv/lib/python3.12/site-packages/ics/event.pyr   r      s    Or#   r   c            %       B   e Zd ZdZ G d d      Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d:dedededed	ed
edededededede	e
   de	e   de	e   dedededdf$dZdefdZdefdZedefd       Zej&                  defd       Zedefd       Zej&                  defd       Zedee   fd        Zej&                  defd!       Zedee   fd"       Zej&                  deeeef   eeef   edf   fd#       Zed$        Zd;d%Zedee   fd&       Zej&                  dee   fd'       Zed(        Z e j&                  d)        Z defd*Z!defd+Z"defd,Z#defd-Z$e$Z%defd.Z&defd/Z'e'Z(defd0Z)defd1Z*defd2Z+defd3Z,d4e-defd5Z.defd6Z/d7 Z0e0Z1d8 Z2de3fd9Z4y)<EventaG  A calendar event.

    Can be full-day or between two instants.
    Can be defined by a beginning instant and
    a duration *or* end instant.

    Unsupported event attributes can be found in `event.extra`,
    a :class:`ics.parse.Container`. You may add some by appending a
    :class:`ics.parse.ContentLine` to `.extra`
    c                       e Zd ZdZeZeZy)
Event.MetaVEVENTN)r   r   r   namer   parserr   
serializerr"   r#   r$   Metar(   $   s    $
r#   r-   Nr*   beginenddurationuiddescriptioncreatedlast_modifiedlocationurltransparentalarms	attendees
categoriesstatus	organizerclassificationreturnc                    d| _         d| _        d| _        d| _        d| _        d| _        || _        |s
t               n|| _        || _	        t        |      | _        t        |      | _        |	| _        |
| _        || _        t!               | _        t%               | _        t%               | _        || _        t-        d      | _        || _        || _        |r|rt5        d      |r|| _        n	|r|| _        |t!        |      | _        || _        || _        |$| j(                  j?                  t%        |             |%| j&                  j?                  t%        |             yy)ay  Instantiates a new :class:`ics.event.Event`.

        Args:
            name: rfc5545 SUMMARY property
            begin (Arrow-compatible)
            end (Arrow-compatible)
            duration
            uid: must be unique
            description
            created (Arrow-compatible)
            last_modified (Arrow-compatible)
            location
            url
            transparent
            alarms
            attendees
            categories
            status
            organizer
            classification

        Raises:
            ValueError: if `end` and `duration` are specified at the same time
        Nr)   )r*   zNEvent() may not specify an end and a duration                 at the same time) 	_duration	_end_time_begin_begin_precision_status_classificationr<   r   r1   r2   r   r3   r4   r5   r6   r7   listr8   setr9   r:   geor   extrar*   r.   
ValueErrorr/   r0   r;   r=   update)selfr*   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   rH   r=   s                      r$   __init__zEvent.__init__)   sB   Z /3.2+/ $&*.2.7),	#*5,5g,>2;M2J'/"%+6'+v(+$'EH-
	
"# # DH$DMv,DK,!OO""3z?3 NN!!#i.1 !r#   c                 H    t        | j                  xs | j                        S )z;
        Return:
            bool: self has an end
        )boolrA   r@   rL   s    r$   has_endzEvent.has_end   s    
 DNN4dnn55r#   attendeec                 :    | j                   j                  |       y)z. Add an attendee to the attendees set
        N)r9   add)rL   rR   s     r$   add_attendeezEvent.add_attendee   s     	8$r#   c                     | j                   S )a  Get or set the beginning of the event.

        |  Will return an :class:`Arrow` object.
        |  May be set to anything that :func:`Arrow.get` understands.
        |  If an end is defined (not a duration), .begin must not
            be set to a superior value.
        )rB   rP   s    r$   r.   zEvent.begin   s     {{r#   valuec                     t        |      }|r&| j                  r|| j                  kD  rt        d      || _        d| _        y )NzBegin must be before endsecond)r   rA   rJ   rB   rC   rL   rW   s     r$   r.   zEvent.begin   s;    % T^^(>788 (r#   c                 (   | j                   r| j                  | j                   z   S | j                  r$| j                  r| j                  S | j                  S | j                  r1| j                  r| j                  t        d      z   S | j                  S y)a  Get or set the end of the event.

        |  Will return an :class:`Arrow` object.
        |  May be set to anything that :func:`Arrow.get` understands.
        |  If set to a non null value, removes any already
            existing duration.
        |  Setting to None will have unexpected behavior if
            begin is not None.
        |  Must not be set to an inferior value than self.begin.
        r   daysN)r@   r.   rA   all_dayrB   r   rP   s    r$   r/   z	Event.end   sq     >>::..^^||~~%~~%[[||{{YA%666 {{"r#   c                     t        |      }|r&| j                  r|| j                  k  rt        d      || _        |rd | _        y y )NzEnd must be after begin)r   rB   rJ   rA   r@   rZ   s     r$   r/   z	Event.end   sB    % T[[UT[[%8677!DN r#   c                 ~    | j                   r| j                   S | j                  r| j                  | j                  z
  S y)a/  Get or set the duration of the event.

        |  Will return a timedelta object.
        |  May be set to anything that timedelta() understands.
        |  May be set with a dict ({"days":2, "hours":6}).
        |  If set to a non null value, removes any already
            existing end time.
        N)r@   r/   r.   rP   s    r$   r0   zEvent.duration   s4     >>>>!XX88djj(( r#   c                     t        |t              rt        di |}n t        |t              r|}n|t        |      }|rd | _        || _        y )Nr"   )
isinstancedictr   rA   r@   rZ   s     r$   r0   zEvent.duration   sI    eT"&&Ey)Ee$E!DNr#   c                     | j                   S )a  Get or set the geo position of the event.

        |  Will return a namedtuple object.
        |  May be set to any Geo, tuple or dict with latitude and longitude keys.
        |  If set to a non null value, removes any already
            existing geo.
        )_georP   s    r$   rH   z	Event.geo   s     yyr#   c                     t        |t              r|d   |d   }}t        ||      }|| _        y ||\  }}t        ||      }|| _        y )Nr   r   )rb   rc   r   re   )rL   rW   r   r   s       r$   rH   z	Event.geo   sY    eT""'
"3U;5GiH),E 	 "'Hi),E	r#   c                      | j                   dk(  S )zD
        Return:
            bool: self is an all-day event
        day)rC   rP   s    r$   r^   zEvent.all_day   s     $$--r#   c                     | j                   ry| j                  j                  d      }| j                  j                  d      }|| _        ||k(  rd| _        n|t        d      z   | _        d| _        d| _        y)zvTransforms self to an all-day event.

        The event will span all the days from the begin to the end day.
        Nrh   r   r\   )	r^   r.   floorr/   rB   rA   r   r@   rC   )rL   	begin_dayend_days      r$   make_all_dayzEvent.make_all_day  sl    
 <<JJ$$U+	((..' !DN$ya'88DN %r#   c                     | j                   S N)rD   rP   s    r$   r;   zEvent.status  s    ||r#   c                     t        |t              r|j                         }d}||vr4t        ddj	                  |D cg c]  }t        |       c}      z        || _        y c c}w )N)N	TENTATIVE	CONFIRMED	CANCELLEDzstatus must be one of %sz, )rb   strupperrJ   joinreprrD   )rL   rW   statusesxs       r$   r;   zEvent.status#  s]    eS!KKME@ 7$))V^D_QRT!WD_:``aa E`s   A#c                     | j                   S ro   )rE   rP   s    r$   r=   zEvent.classification,  s    ###r#   c                 \    |#t        |t              st        d      || _        y d | _        y )Nzclassification must be a str)rb   rt   rJ   rE   rZ   s     r$   r=   zEvent.classification0  s.    eS) !?@@#(D #'D r#   c                 j   | j                   rdj                  | j                         nd}| j                  r| j                  sJ | j                  r| j                  | j                  k(  r+dj                  || j
                  j                  d            S dj                  || j                  j                  d      | j                  j                  d            S | j
                  )| j                   rdj                  | j                         S dS dj                  || j
                  | j                        S )	Nz'{}'  z<all-day Event {}{}>z%Y-%m-%dz!<all-day Event {}begin:{} end:{}>z<Event '{}'>z<Event>z<Event {}begin:{} end:{}>)r*   formatr^   rB   rA   r.   strftimer/   )rL   r*   s     r$   __repr__zEvent.__repr__9  s    ,0IIw~~dii(2<<;;;>>T[[DNN%B-44T4::;N;Nz;Z[[:AA$H\H\]gHhjnjxjx  kB  kB  CM  kN  O  OZZ7;yy>((3OiO.55dDJJQQr#   c                     t        |t              s#t        dj                  t	        |                  | j
                  |j
                  k\  xr | j
                  |j                  k  S NCannot compare Event and {})rb   r&   NotImplementedErrorr~   typer.   r/   rL   others     r$   starts_withinzEvent.starts_withinF  sR    %'%-44T%[AC CzzU[[(DTZZ599-DDr#   c                     t        |t              s#t        dj                  t	        |                  | j
                  |j                  k\  xr | j
                  |j
                  k  S r   )rb   r&   r   r~   r   r/   r.   r   s     r$   ends_withinzEvent.ends_withinL  sR    %'%-44T%[AC Cxx5;;&@488uyy+@@r#   c                     t        |t              s#t        dj                  t	        |                  | j                  |      xs7 | j                  |      xs$ |j                  |       xs |j                  |       S r   )rb   r&   r   r~   r   r   r   r   s     r$   
intersectszEvent.intersectsR  s{    %'%-44T%[AC C""5) +##E*+&&t,+ $$T*	,r#   c                    t        |t              r$|j                  |       xr |j                  |       S t        |t              r | j
                  |k  xr | j                  |k\  S t        dj                  t        |                  r   )
rb   r&   r   r   r   r.   r/   r   r~   r   r   s     r$   includeszEvent.includes]  ss    eU#&&t,H1B1B41HHeX&::&<488u+<<!)00e=? 	?r#   c                     t        |t              r|j                  |       S t        dj	                  t        |                  r   )rb   r&   r   r   r~   r   r   s     r$   is_included_inzEvent.is_included_ine  s:    eU#>>$''!)00e=? 	?r#   c                 8   t        |t              r| j                  X|j                  L| j                  |j                  y| j                  y|j                  y| j                  |j                  k  S | j                  |j                  k(  r3| j                  y|j                  y| j                  |j                  k  S | j                  |j                  k  S t        |t
              r| j                  |k  S t        dj                  t        |                  )NFTr   	rb   r&   r.   r*   r/   r   r   r~   r   r   s     r$   __lt__zEvent.__lt__m  s    eU#zz!ekk&999$); YY&ZZ' 99uzz11 u{{*88#YY& 88eii//zzEKK//eX&::%%!)00e=? 	?r#   c                 8   t        |t              r| j                  X|j                  L| j                  |j                  y| j                  y|j                  y| j                  |j                  k  S | j                  |j                  k(  r3| j                  y|j                  y| j                  |j                  k  S | j                  |j                  k  S t        |t
              r| j                  |k  S t        dj                  t        |                  )NTFr   r   r   s     r$   __le__zEvent.__le__  s    eU#zz!ekk&999$);YY&ZZ' 99

22u{{*88#YY& 88uyy00zzU[[00eX&::&&!)00e=? 	?r#   c                 &    | j                  |       S ro   )r   r   s     r$   __gt__zEvent.__gt__      ;;u%%%r#   c                 &    | j                  |       S ro   )r   r   s     r$   __ge__zEvent.__ge__  r   r#   r   c                    t        |t              r| j                  |j                  k(  xr| | j                  |j                  k(  xr` | j                  |j                  k(  xrD | j
                  |j
                  k(  xr( | j                  |j                  k(  xr | j                  |j                  k(  xr | j                  |j                  k(  xr | j                  |j                  k(  xr | j                  |j                  k(  xr | j                  |j                  k(  xr | j                  |j                  k(  xrj | j                  |j                  k(  xrO | j                  |j                  k(  xr4 | j                  |j                  k(  xr | j                   |j                   k(  S t#        dj%                  t'        |                  r   )rb   r&   r*   r.   r/   r0   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r   r~   r   r   s     r$   __eq__zEvent.__eq__  s   eU#II+ 2

ekk)2EII%2 /2   E$5$55	2
 -2 ""e&9&992 /2 EII%2   E$5$552 u||+2 %//12 5#3#332 u||+2 %//13 ")00e=? 	?r#   c                 j    | j                   |j                   k(  xr | j                  |j                  k(  S ro   )r.   r/   r   s     r$   time_equalszEvent.time_equals  s'    

ekk)FEII0EFr#   c                 F   t        |i |}| j                  |      rk| j                  |      r|j                  |_        n| j                  |_        | j	                  |      r|j
                  |_        |S | j
                  |_        |S t        dj                  | |            )zCreate a new event which covers the time range of two intersecting events

        All extra parameters are passed to the Event constructor.

        Args:
            other: the other event

        Returns:
            a new Event instance
        z-Cannot join {} with {}: they don't intersect.)r&   r   r   r.   r   r/   rJ   r~   )rL   r   argskwargevents        r$   rv   z
Event.join  s     t%u%??5!!!%(#kk"jj&!II	 L !HH	LIPPQUW\]^^r#   c                     t        j                   |       }|j                  j                         |_        t        j                   | j                        |_        t        j                   | j                        |_        |S )z:
        Returns:
            Event: an exact copy of self)copyrI   cloner8   r:   )rL   r   s     r$   r   zEvent.clone  sS     		$kk'')yy-99T__5r#   c                 `    t        dj                  t        d | j                                    S )zC
        Returns:
            int: hash of self. Based on self.uid.r}   c                     dt        |       z  S )Nz%.3d)ord)ry   s    r$   <lambda>z Event.__hash__.<locals>.<lambda>  s    #a& r#   )intrv   mapr1   rP   s    r$   __hash__zEvent.__hash__  s$     27738$((CDEEr#   )NNNNNNNNNNNNNNNNNN)r>   N)5r   r   r   __doc__r-   rt   r   r   rO   r   r   r   r   rM   rQ   rU   propertyr   r.   setterr/   r	   r0   r   rH   r   r   r    r   r^   rm   r;   r=   r   r   r   r   __xor__r   r   __in__r   r   r   r   objectr   r   rv   __and__r   r   r   r"   r#   r$   r&   r&      s   	% % "$("&'+ $(&*,0!% %)/315-1#(,'+%W2W2!W2  W2 %	W2
 W2 "W2 $W2 !*W2 W2 W2 #W2 "),W2 %X.W2 &c]W2 W2  &!W2$ "%%W2& 'W2r6 6%X %
 u   \\)9 ) ) U  : 	ZZ" " " (9-  $ __i   Xc]   	ZZtCJ/ue|1Dc4OP   . .&.    ]]HSM   $ $ ( (R# REd EAD A,4 , G? ??t ? F?t ?8?t ?2&t &&t &?F ?t ?(GD G_4 GF# Fr#   r&   )"r   r   r   typingr   r   r   r   r	   r
   r   r   arrowr   
alarm.baser   rR   r   r   	componentr   ics.grammar.parser   typesr   utilsr   r   ics.parsers.event_parserr    ics.serializers.event_serializerr   r   r&   r"   r#   r$   <module>r      sS     (" " "  ! )   '  ' 0 <* 
RFI RFr#   