Ë
    äÞËj„3  ã                  óÚ   — d dl mZ d dlZd dlZd dlZd dlmZ d dlmZm	Z	 d dl
mZ dZdZ G d„ de«      Z G d	„ d
«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de	«      Zy)é    )ÚannotationsN)ÚPath)Ú
BaseThreadÚProtocol)ÚSkipRepeatsQueueé   c                  ó   — e Zd ZdZy)Ú
EventQueuea.  Thread-safe event queue based on a special queue that skips adding
    the same event (:class:`FileSystemEvent`) multiple times consecutively.
    Thus avoiding dispatching multiple event handling
    calls when multiple identical events are produced quicker than an observer
    can consume them.
    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úS/var/www/photos/backend/venv/lib/python3.12/site-packages/watchdog/observers/api.pyr
   r
      s   „ òr   r
   c                  óp   — e Zd ZdZdd„Zed„ «       Zed„ «       Zed„ «       Zed„ «       Z	d„ Z
d	„ Zd
„ Zd„ Zy)ÚObservedWatchzüAn scheduled watch.

    :param path:
        Path string.
    :param recursive:
        ``True`` if watch is recursive; ``False`` otherwise.
    :param event_filter:
        Optional collection of :class:`watchdog.events.FileSystemEvent` to watch
    Nc                óŠ   — t        |t        «      rt        |«      n|| _        || _        |�t        |«      | _        y d | _        y ©N)Ú
isinstancer   ÚstrÚ_pathÚ_is_recursiveÚ	frozensetÚ_event_filter)ÚselfÚpathÚ	recursiveÚevent_filters       r   Ú__init__zObservedWatch.__init__2   s:   € Ü",¨T´4Ô"8”S˜”Y¸dˆŒ
Ø&ˆÔØ8DÐ8PœY |Ó4ˆÕÐVZˆÕr   c                ó   — | j                   S )z"The path that this watch monitors.)r   ©r   s    r   r   zObservedWatch.path7   s   € ð �z‰zÐr   c                ó   — | j                   S )z;Determines whether subdirectories are watched for the path.)r   r"   s    r   Úis_recursivezObservedWatch.is_recursive<   ó   € ð ×!Ñ!Ð!r   c                ó   — | j                   S )z.Collection of event types watched for the path)r   r"   s    r   r   zObservedWatch.event_filterA   r%   r   c                óH   — | j                   | j                  | j                  fS r   )r   r$   r   r"   s    r   ÚkeyzObservedWatch.keyF   s   € à�y‰y˜$×+Ñ+¨T×->Ñ->Ð>Ð>r   c                ó4   — | j                   |j                   k(  S r   ©r(   ©r   Úwatchs     r   Ú__eq__zObservedWatch.__eq__J   ó   € Ø�x‰x˜5Ÿ9™9Ñ$Ð$r   c                ó4   — | j                   |j                   k7  S r   r*   r+   s     r   Ú__ne__zObservedWatch.__ne__M   r.   r   c                ó,   — t        | j                  «      S r   )Úhashr(   r"   s    r   Ú__hash__zObservedWatch.__hash__P   s   € Ü�D—H‘H‹~Ðr   c                óê   — | j                   �1dj                  t        d„ | j                   D «       «      «      }d|› �}nd}dt        | «      j                  › d| j
                  ›d| j                  › |› d�S )	Nú|c              3  ó4   K  — | ]  }|j                   –— Œ y ­wr   )r   )Ú.0Ú_clss     r   ú	<genexpr>z)ObservedWatch.__repr__.<locals>.<genexpr>U   s   è ø€ Ò.[À¨t¯}­}Ñ.[ùs   ‚z, event_filter=Ú ú<z: path=z, is_recursive=ú>)r   ÚjoinÚsortedÚtyper   r   r$   )r   Úevent_filter_strs     r   Ú__repr__zObservedWatch.__repr__S   s{   € Ø×ÑÐ(Ø"Ÿx™x¬Ñ.[È×IZÑIZÔ.[Ó([Ó\ÐØ!0Ð1AÐ0BÐCÑà!ÐØ”4˜“:×&Ñ&Ð' w¨t¯y©y¨m¸?È4×K\ÑK\ÐJ]Ð^nÐ]oÐopÐqÐqr   r   )r   r   r   r   r    Úpropertyr   r$   r   r(   r-   r0   r3   rA   r   r   r   r   r   '   sr   „ ñó[ð
 ñó ðð ñ"ó ð"ð ñ"ó ð"ð ñ?ó ð?ò%ò%òórr   r   c                  óZ   ‡ — e Zd ZdZedfˆ fd„	Zed„ «       Zed„ «       Zd„ Z	d„ Z
d„ Zˆ xZS )	ÚEventEmitteraÍ  Producer thread base class subclassed by event emitters
    that generate events and populate a queue with them.

    :param event_queue:
        The event queue to populate with generated events.
    :type event_queue:
        :class:`watchdog.events.EventQueue`
    :param watch:
        The watch to observe and produce events for.
    :type watch:
        :class:`ObservedWatch`
    :param timeout:
        Timeout (in seconds) between successive attempts at reading events.
    :type timeout:
        ``float``
    :param event_filter:
        Collection of event types to emit, or None for no filtering (default).
    :type event_filter:
        Optional[Iterable[:class:`watchdog.events.FileSystemEvent`]]
    Nc                ó€   •— t         ‰| �  «        || _        || _        || _        |�t        |«      | _        y d | _        y r   )Úsuperr    Ú_event_queueÚ_watchÚ_timeoutr   r   )r   Úevent_queuer,   Útimeoutr   Ú	__class__s        €r   r    zEventEmitter.__init__s   s>   ø€ Ü‰ÑÔØ'ˆÔØˆŒØˆŒØ8DÐ8PœY |Ó4ˆÕÐVZˆÕr   c                ó   — | j                   S )z$Blocking timeout for reading events.©rI   r"   s    r   rK   zEventEmitter.timeoutz   ó   € ð �}‰}Ðr   c                ó   — | j                   S )z'The watch associated with this emitter.)rH   r"   s    r   r,   zEventEmitter.watch   s   € ð �{‰{Ðr   c                óª   ‡— | j                   �t        ˆfd„| j                   D «       «      r(| j                  j                  ‰| j                  f«       yy)zÊQueues a single event.

        :param event:
            Event to be queued.
        :type event:
            An instance of :class:`watchdog.events.FileSystemEvent`
            or a subclass.
        Nc              3  ó6   •K  — | ]  }t        ‰|«      –— Œ y ­wr   )r   )r7   ÚclsÚevents     €r   r9   z+EventEmitter.queue_event.<locals>.<genexpr>�   s   øè ø€ Ò,bÈ¬Z¸¸s×-CÑ,bùs   ƒ)r   ÚanyrG   Úputr,   )r   rT   s    `r   Úqueue_eventzEventEmitter.queue_event„   sG   ø€ ð ×ÑÐ%¬Ó,bÈt×OaÑOaÔ,bÔ)bØ×Ñ×!Ñ! 5¨$¯*©*Ð"5Õ6ð *cr   c                 ó   — y)a  Override this method to populate the event queue with events
        per interval period.

        :param timeout:
            Timeout (in seconds) between successive attempts at
            reading events.
        :type timeout:
            ``float``
        Nr   ©r   rK   s     r   Úqueue_eventszEventEmitter.queue_events�   ó   � r   c                ó~   — | j                  «       r-| j                  | j                  «       | j                  «       rŒ,y y r   )Úshould_keep_runningrZ   rK   r"   s    r   ÚrunzEventEmitter.run›   s.   € Ø×&Ñ&Ô(Ø×Ñ˜dŸl™lÔ+ð ×&Ñ&×(r   )r   r   r   r   ÚDEFAULT_EMITTER_TIMEOUTr    rB   rK   r,   rW   rZ   r^   Ú__classcell__©rL   s   @r   rD   rD   ]   sN   ø„ ñð* 4KÐY]õ [ð ñó ðð ñó ðò
7ò	ö,r   rD   c                  óh   ‡ — e Zd ZdZ e«       Z	 efˆ fd„	Zed„ «       Z	d„ Z
ed„ «       Zd„ Zd„ Zˆ xZS )ÚEventDispatchera7  Consumer thread base class subclassed by event observer threads
    that dispatch events from an event queue to appropriate event handlers.

    :param timeout:
        Timeout value (in seconds) passed to emitters
        constructions in the child class BaseObserver.
    :type timeout:
        ``float``
    c                óN   •— t         ‰| �  «        t        «       | _        || _        y r   )rF   r    r
   rG   rI   )r   rK   rL   s     €r   r    zEventDispatcher.__init__®   s   ø€ Ü‰ÑÔÜ&›LˆÔØˆ�r   c                ó   — | j                   S )z)Timeout value to construct emitters with.rN   r"   s    r   rK   zEventDispatcher.timeout³   rO   r   c                óð   — t        j                  | «       t        j                  t        j
                  «      5  | j                  j                  t        j                  «       d d d «       y # 1 sw Y   y xY wr   )
r   ÚstopÚ
contextlibÚsuppressÚqueueÚFullrJ   Ú
put_nowaitrc   Ú
stop_eventr"   s    r   rg   zEventDispatcher.stop¸   sS   € Ü�‰˜ÔÜ× Ñ ¤§¡Ó,ñ 	DØ×Ñ×'Ñ'¬×(BÑ(BÔC÷	D÷ 	Dñ 	Dús   ¹*A,Á,A5c                ó   — | j                   S )zœThe event queue which is populated with file system events
        by emitters and from which events are dispatched by a dispatcher
        thread.
        )rG   r"   s    r   rJ   zEventDispatcher.event_queue½   s   € ð × Ñ Ð r   c                 ó   — y)ag  Override this method to consume events from an event queue, blocking
        on the queue for the specified timeout before raising :class:`queue.Empty`.

        :param event_queue:
            Event queue to populate with one set of events.
        :type event_queue:
            :class:`EventQueue`
        :raises:
            :class:`queue.Empty`
        Nr   )r   rJ   s     r   Údispatch_eventszEventDispatcher.dispatch_eventsÅ   r[   r   c                ó²   — | j                  «       r.	 | j                  | j                  «       | j                  «       rŒ-y y # t        j                  $ r Y ŒTw xY wr   )r]   rp   rJ   rj   ÚEmptyr"   s    r   r^   zEventDispatcher.runÑ   sM   € Ø×&Ñ&Ô(ðØ×$Ñ$ T×%5Ñ%5Ô6ð ×&Ñ&×(øô —;‘;ò Ùðús   ’A  Á AÁA)r   r   r   r   Úobjectrm   ÚDEFAULT_OBSERVER_TIMEOUTr    rB   rK   rg   rJ   rp   r^   r`   ra   s   @r   rc   rc       sT   ø„ ññ “€JØCà7õ  ð
 ñó ðòDð
 ñ!ó ð!ò
ör   rc   c                  óŠ   ‡ — e Zd ZdZefˆ fd„	Zd„ Zd„ Zd„ Zd„ Z	d„ Z
ed„ «       Zˆ fd	„Zdd
„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zˆ xZS )ÚBaseObserverzBase observer.c                ó¼   •— t         ‰| �  |«       || _        t        j                  «       | _        t        «       | _        i | _        t        «       | _	        i | _
        y r   )rF   r    Ú_emitter_classÚ	threadingÚRLockÚ_lockÚsetÚ_watchesÚ	_handlersÚ	_emittersÚ_emitter_for_watch)r   Úemitter_classrK   rL   s      €r   r    zBaseObserver.__init__Ü   sG   ø€ Ü‰Ñ˜Ô!Ø+ˆÔÜ—_‘_Ó&ˆŒ
Ü›ˆŒØˆŒÜ›ˆŒØ"$ˆÕr   c                ól   — || j                   |j                  <   | j                  j                  |«       y r   )r€   r,   r   Úadd©r   Úemitters     r   Ú_add_emitterzBaseObserver._add_emitterå   s(   € Ø18ˆ×Ñ §¡Ñ.Ø�‰×Ñ˜7Õ#r   c                ó  — | j                   |j                  = | j                  j                  |«       |j	                  «        t        j                  t        «      5  |j                  «        d d d «       y # 1 sw Y   y xY wr   )	r€   r,   r   Úremoverg   rh   ri   ÚRuntimeErrorr=   r„   s     r   Ú_remove_emitterzBaseObserver._remove_emitteré   s[   € Ø×#Ñ# G§M¡MÐ2Ø�‰×Ñ˜gÔ&Ø�‰ŒÜ× Ñ ¤Ó.ñ 	Ø�L‰LŒN÷	÷ 	ñ 	ús   ÁA6Á6A?c                óL  — | j                   D ]  }|j                  «        Œ | j                   D ]4  }t        j                  t        «      5  |j                  «        d d d «       Œ6 | j                   j                  «        | j                  j                  «        y # 1 sw Y   ŒuxY wr   )r   rg   rh   ri   r‰   r=   Úclearr€   r„   s     r   Ú_clear_emitterszBaseObserver._clear_emittersð   s†   € Ø—~‘~ò 	ˆGØ�L‰L�Nð	à—~‘~ò 	ˆGÜ×$Ñ$¤\Ó2ñ Ø—‘”÷ð ð	ð 	�‰×ÑÔØ×Ñ×%Ñ%Õ'÷ð ús   Á
BÂB#	c                óŠ   — || j                   vrt        «       | j                   |<   | j                   |   j                  |«       y r   )r~   r|   rƒ   ©r   Úevent_handlerr,   s      r   Ú_add_handler_for_watchz#BaseObserver._add_handler_for_watchù   s5   € Ø˜Ÿ™Ñ&Ü$'£EˆD�N‰N˜5Ñ!Ø�‰�uÑ×!Ñ! -Õ0r   c                ó   — | j                   |= y r   )r~   r+   s     r   Ú_remove_handlers_for_watchz'BaseObserver._remove_handlers_for_watchþ   s   € Ø�N‰N˜5Ñ!r   c                ó   — | j                   S )z/Returns event emitter created by this observer.)r   r"   s    r   ÚemitterszBaseObserver.emitters  s   € ð �~‰~Ðr   c                óÀ   •— | j                   j                  «       D ]  }	 |j                  «        Œ t
        ‰| �	  «        y # t        $ r | j	                  |«       ‚ w xY wr   )r   ÚcopyÚstartÚ	ExceptionrŠ   rF   )r   r…   rL   s     €r   r˜   zBaseObserver.start  sZ   ø€ Ø—~‘~×*Ñ*Ó,ò 	ˆGðØ—‘•ð	ô 	‰‰�øô ò Ø×$Ñ$ WÔ-Øðús    AÁAc                ó¨  — | j                   5  t        |||«      }| j                  ||«       | j                  j	                  |«      €Z| j                  | j                  || j                  |¬«      }| j                  «       r|j                  «        | j                  |«       | j                  j                  |«       ddd«       |S # 1 sw Y   S xY w)a9  Schedules watching a path and calls appropriate methods specified
        in the given event handler in response to file system events.

        :param event_handler:
            An event handler instance that has appropriate event handling
            methods which will be called by the observer in response to
            file system events.
        :type event_handler:
            :class:`watchdog.events.FileSystemEventHandler` or a subclass
        :param path:
            Directory path that will be monitored.
        :type path:
            ``str``
        :param recursive:
            ``True`` if events will be emitted for sub-directories
            traversed recursively; ``False`` otherwise.
        :type recursive:
            ``bool``
        :param event_filter:
            Collection of event types to emit, or None for no filtering (default).
        :type event_filter:
            Optional[Iterable[:class:`watchdog.events.FileSystemEvent`]]
        :return:
            An :class:`ObservedWatch` object instance representing
            a watch.
        N)rK   r   )r{   r   r‘   r€   Úgetrx   rJ   rK   Úis_aliver˜   r†   r}   rƒ   )r   r�   r   r   r   r,   r…   s          r   ÚschedulezBaseObserver.schedule  s¶   € ð6 �Z‰Zñ 
	%Ü! $¨	°<Ó@ˆEØ×'Ñ'¨°uÔ=ð ×&Ñ&×*Ñ*¨5Ó1Ð9Ø×-Ñ-¨d×.>Ñ.>ÀÈtÏ|É|ÐjvÐ-Ów�Ø—=‘=”?Ø—M‘M”OØ×!Ñ! 'Ô*Ø�M‰M×Ñ˜eÔ$÷
	%ð ˆ÷
	%ð ˆús   �B0CÃCc                ój   — | j                   5  | j                  ||«       ddd«       y# 1 sw Y   yxY w)a!  Adds a handler for the given watch.

        :param event_handler:
            An event handler instance that has appropriate event handling
            methods which will be called by the observer in response to
            file system events.
        :type event_handler:
            :class:`watchdog.events.FileSystemEventHandler` or a subclass
        :param watch:
            The watch to add a handler for.
        :type watch:
            An instance of :class:`ObservedWatch` or a subclass of
            :class:`ObservedWatch`
        N)r{   r‘   r�   s      r   Úadd_handler_for_watchz"BaseObserver.add_handler_for_watch7  s0   € ð �Z‰Zñ 	>Ø×'Ñ'¨°uÔ=÷	>÷ 	>ñ 	>ús   �)©2c                ó‚   — | j                   5  | j                  |   j                  |«       ddd«       y# 1 sw Y   yxY w)a'  Removes a handler for the given watch.

        :param event_handler:
            An event handler instance that has appropriate event handling
            methods which will be called by the observer in response to
            file system events.
        :type event_handler:
            :class:`watchdog.events.FileSystemEventHandler` or a subclass
        :param watch:
            The watch to remove a handler for.
        :type watch:
            An instance of :class:`ObservedWatch` or a subclass of
            :class:`ObservedWatch`
        N)r{   r~   rˆ   r�   s      r   Úremove_handler_for_watchz%BaseObserver.remove_handler_for_watchI  s7   € ð �Z‰Zñ 	8Ø�N‰N˜5Ñ!×(Ñ(¨Ô7÷	8÷ 	8ñ 	8ús   �5µ>c                óÖ   — | j                   5  | j                  |   }| j                  |= | j                  |«       | j                  j                  |«       ddd«       y# 1 sw Y   yxY w)zÔUnschedules a watch.

        :param watch:
            The watch to unschedule.
        :type watch:
            An instance of :class:`ObservedWatch` or a subclass of
            :class:`ObservedWatch`
        N)r{   r€   r~   rŠ   r}   rˆ   )r   r,   r…   s      r   Ú
unschedulezBaseObserver.unschedule[  s\   € ð �Z‰Zñ 	(Ø×-Ñ-¨eÑ4ˆGØ—‘˜uÐ%Ø× Ñ  Ô)Ø�M‰M× Ñ  Ô'÷		(÷ 	(ñ 	(ús   �A	AÁA(c                óÎ   — | j                   5  | j                  j                  «        | j                  «        | j                  j                  «        ddd«       y# 1 sw Y   yxY w)zTUnschedules all watches and detaches all associated event
        handlers.
        N)r{   r~   rŒ   r�   r}   r"   s    r   Úunschedule_allzBaseObserver.unschedule_allj  sL   € ð �Z‰Zñ 	"Ø�N‰N× Ñ Ô"Ø× Ñ Ô"Ø�M‰M×ÑÔ!÷	"÷ 	"ñ 	"ús   �AAÁA$c                ó$   — | j                  «        y r   )r¥   r"   s    r   Úon_thread_stopzBaseObserver.on_thread_stops  s   € Ø×ÑÕr   c                óp  — |j                  d¬«      }|t        j                  u ry |\  }}| j                  5  t	        | j
                  j                  |g «      «      D ]2  }|| j
                  j                  |g «      v sŒ"|j                  |«       Œ4 	 d d d «       |j                  «        y # 1 sw Y   ŒxY w)NT)Úblock)r›   rc   rm   r{   Úlistr~   ÚdispatchÚ	task_done)r   rJ   ÚentryrT   r,   Úhandlers         r   rp   zBaseObserver.dispatch_eventsv  s¤   € Ø—‘ d�Ó+ˆØ”O×.Ñ.Ñ.ØØ‰ˆˆuà�Z‰Zñ 	,ô   §¡× 2Ñ 2°5¸"Ó =Ó>ò ,�Ø˜dŸn™n×0Ñ0°¸Ó;Ò;Ø×$Ñ$ UÕ+ñ,÷		,ð 	×ÑÕ÷	,ð 	,ús   ·AB,Á?B,Â,B5)FN)r   r   r   r   rt   r    r†   rŠ   r�   r‘   r“   rB   r•   r˜   r�   rŸ   r¡   r£   r¥   r§   rp   r`   ra   s   @r   rv   rv   Ù   sd   ø„ Ùà.Fõ %ò$òò(ò1ò
"ð ñó ðôó&òP>ò$8ò$(ò"òö r   rv   c                  ó   — e Zd Zddd„Zy)ÚBaseObserverSubclassCallablec                 ó   — y r   r   rY   s     r   Ú__call__z%BaseObserverSubclassCallable.__call__‡  r[   r   N).)rK   ÚfloatÚreturnrv   )r   r   r   r²   r   r   r   r°   r°   †  s   „ ÝAr   r°   )Ú
__future__r   rh   rj   ry   Úpathlibr   Úwatchdog.utilsr   r   Úwatchdog.utils.bricksr   r_   rt   r
   r   rD   rc   rv   r°   r   r   r   ú<module>r¹      s{   ðõ  #ã Û Û Ý ç /Ý 2àÐ ØÐ ôÐ!ô ÷2rñ 2rôl@,�:ô @,ôF6�jô 6ôrj �?ô j ôZB 8õ Br   