Ë
    êmxiê5  ã                  óì   — 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 d dl	m
Z
 d dlmZ d dlmZ e
rd dlmZ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y)é    )ÚannotationsN)Údefaultdict)ÚPath)ÚTYPE_CHECKING)Ú
BaseThread)ÚSkipRepeatsQueue)ÚFileSystemEventÚFileSystemEventHandlerg      ð?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__© ó    úM/home/htdocs/ttos/venv/lib/python3.12/site-packages/watchdog/observers/api.pyr   r      s   „ òr   r   c                  ó†   — e Zd ZdZddœdd„Zedd„«       Zedd„«       Zedd„«       Zedd„«       Z	dd	„Z
dd
„Zdd„Zd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
    N)Úevent_filterc               óŠ   — t        |t        «      rt        |«      n|| _        || _        |�t        |«      | _        y d | _        y ©N)Ú
isinstancer   ÚstrÚ_pathÚ_is_recursiveÚ	frozensetÚ_event_filter)ÚselfÚpathÚ	recursiver   s       r   Ú__init__zObservedWatch.__init__(   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.path-   s   € ð �z‰zÐr   c                ó   — | j                   S )z;Determines whether subdirectories are watched for the path.)r   r$   s    r   Úis_recursivezObservedWatch.is_recursive2   ó   € ð ×!Ñ!Ð!r   c                ó   — | j                   S )z.Collection of event types watched for the path)r   r$   s    r   r   zObservedWatch.event_filter7   r'   r   c                óH   — | j                   | j                  | j                  fS r   )r    r&   r   r$   s    r   ÚkeyzObservedWatch.key<   s   € à�y‰y˜$×+Ñ+¨T×->Ñ->Ð>Ð>r   c                ó`   — t        |t        «      st        S | j                  |j                  k(  S r   ©r   r   ÚNotImplementedr*   ©r   Úwatchs     r   Ú__eq__zObservedWatch.__eq__@   ó%   € Ü˜%¤Ô/Ü!Ð!Ø�x‰x˜5Ÿ9™9Ñ$Ð$r   c                ó`   — t        |t        «      st        S | j                  |j                  k7  S r   r,   r.   s     r   Ú__ne__zObservedWatch.__ne__E   r1   r   c                ó,   — t        | j                  «      S r   )Úhashr*   r$   s    r   Ú__hash__zObservedWatch.__hash__J   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>O   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__M   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    z
str | Pathr!   Úboolr   ú"list[type[FileSystemEvent]] | None)Úreturnr   )rG   rE   )rG   z'frozenset[type[FileSystemEvent]] | None)rG   z9tuple[str, bool, frozenset[type[FileSystemEvent]] | None])r/   ÚobjectrG   rE   )rG   Úint)r   r   r   r   r"   Úpropertyr    r&   r   r*   r0   r3   r6   rD   r   r   r   r   r      sy   „ ñð quõ [ð
 òó ðð ò"ó ð"ð ò"ó ð"ð ò?ó ð?ó%ó
%ó
ôrr   r   c                  óz   ‡ — e Zd ZdZeddœ	 	 	 	 	 	 	 	 	 d
ˆ fd„Zedd„«       Zedd„«       Zdd„Z	dd„Z
d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:
        Iterable[:class:`watchdog.events.FileSystemEvent`] | None
    N©Útimeoutr   c               ó€   •— t         ‰| �  «        || _        || _        || _        |�t        |«      | _        y d | _        y r   )Úsuperr"   Ú_event_queueÚ_watchÚ_timeoutr   r   )r   Úevent_queuer/   rN   r   Ú	__class__s        €r   r"   zEventEmitter.__init__m   s@   ø€ ô 	‰ÑÔØ'ˆÔØˆŒØˆŒØ8DÐ8PœY |Ó4ˆÕÐVZˆÕr   c                ó   — | j                   S )z$Blocking timeout for reading events.©rS   r$   s    r   rN   zEventEmitter.timeout{   ó   € ð �}‰}Ðr   c                ó   — | j                   S )z'The watch associated with this emitter.)rR   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   )r:   ÚclsÚevents     €r   r<   z+EventEmitter.queue_event.<locals>.<genexpr>Ž   s   øè ø€ Ò,bÈ¬Z¸¸s×-CÑ,bùs   ƒ)r   ÚanyrQ   Úputr/   )r   r]   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   rN   s     r   Úqueue_eventszEventEmitter.queue_events‘   ó   � r   c                ó~   — | j                  «       r-| j                  | j                  «       | j                  «       rŒ,y y r   )Úshould_keep_runningrb   rN   r$   s    r   ÚrunzEventEmitter.runœ   s.   € Ø×&Ñ&Ô(Ø×Ñ˜dŸl™lÔ+ð ×&Ñ&×(r   )
rT   r   r/   r   rN   Úfloatr   rF   rG   ÚNone©rG   rg   )rG   r   )r]   r	   rG   rh   ©rN   rg   rG   rh   ©rG   rh   )r   r   r   r   ÚDEFAULT_EMITTER_TIMEOUTr"   rJ   rN   r/   r`   rb   rf   Ú__classcell__©rU   s   @r   rL   rL   W   s‚   ø„ ñð4 1Ø;?ñ[àð[ð ð[ð
 ð[ð 9ð[ð 
õ[ð òó ðð òó ðó
7ó	÷,r   rL   c                  óv   ‡ — e Zd ZdZ e«       Z	 edœd	ˆ fd„Zed
d„«       Z	dd„Z
edd„«       Zdd„Zd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``
    ©rN   c               óN   •— t         ‰| �  «        t        «       | _        || _        y r   )rP   r"   r   rQ   rS   )r   rN   rU   s     €r   r"   zEventDispatcher.__init__¯   s   ø€ Ü‰ÑÔÜ&›LˆÔØˆ�r   c                ó   — | j                   S )z)Timeout value to construct emitters with.rW   r$   s    r   rN   zEventDispatcher.timeout´   rX   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ÚFullrT   Ú
put_nowaitrp   Ú
stop_eventr$   s    r   ru   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.
        )rQ   r$   s    r   rT   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   rT   s     r   Údispatch_eventszEventDispatcher.dispatch_eventsÆ   rc   r   c                ó²   — | j                  «       r.	 | j                  | j                  «       | j                  «       rŒ-y y # t        j                  $ r Y ŒTw xY wr   )re   r~   rT   rx   ÚEmptyr$   s    r   rf   zEventDispatcher.runÒ   sM   € Ø×&Ñ&Ô(ðØ×$Ñ$ T×%5Ñ%5Ô6ð ×&Ñ&×(øô —;‘;ò Ùðús   ’A  Á AÁArj   ri   rk   )rG   r   ©rT   r   rG   rh   )r   r   r   r   rH   r{   ÚDEFAULT_OBSERVER_TIMEOUTr"   rJ   rN   ru   rT   r~   rf   rm   rn   s   @r   rp   rp   ¡   sT   ø„ ññ “€JØCà+C÷  ð
 òó ðóDð
 ò!ó ð!ó
÷r   rp   c                  óÂ   ‡ — e Zd ZdZedœdˆ fd„Zdd„Zdd„Zdd„Zdd„Z	dd„Z
edd	„«       Zdˆ fd
„Zdddœ	 	 	 	 	 	 	 	 	 dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zˆ xZS )ÚBaseObserverzBase observer.rq   c               óØ   •— t         ‰| �  |¬«       || _        t        j                  «       | _        t        «       | _        t        t        «      | _	        t        «       | _
        i | _        y )Nrq   )rP   r"   Ú_emitter_classÚ	threadingÚRLockÚ_lockÚsetÚ_watchesr   Ú	_handlersÚ	_emittersÚ_emitter_for_watch)r   Úemitter_classrN   rU   s      €r   r"   zBaseObserver.__init__Ý   sP   ø€ Ü‰Ñ ÐÔ)Ø+ˆÔÜ—_‘_Ó&ˆŒ
Ü,/«EˆŒÜR]Ô^aÓRbˆŒÜ,/«EˆŒØEGˆÕ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�   Úremoveru   rv   rw   Ú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�   ru   rv   rw   r—   r@   ÚclearrŽ   r’   s     r   Ú_clear_emitterszBaseObserver._clear_emittersñ   s†   € Ø—~‘~ò 	ˆGØ�L‰L�Nð	à—~‘~ò 	ˆGÜ×$Ñ$¤\Ó2ñ Ø—‘”÷ð ð	ð 	�‰×ÑÔØ×Ñ×%Ñ%Õ'÷ð ús   Á
BÂB#	c                ó@   — | j                   |   j                  |«       y r   )rŒ   r‘   ©r   Úevent_handlerr/   s      r   Ú_add_handler_for_watchz#BaseObserver._add_handler_for_watchú   s   € Ø�‰�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˜   rP   )r   r“   rU   s     €r   r¦   zBaseObserver.start  sZ   ø€ Ø—~‘~×*Ñ*Ó,ò 	ˆGðØ—‘•ð	ô 	‰‰�øô ò Ø×$Ñ$ WÔ-Øðús    AÁAFN©r!   r   c               ó�  — | j                   5  t        |||¬«      }| j                  ||«       || j                  vrZ| j	                  | j
                  || j                  |¬«      }| j                  «       r|j                  «        | j                  |«       | j                  j                  |«       ddd«       |S # 1 sw Y   S xY w)a6  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:
            Iterable[:class:`watchdog.events.FileSystemEvent`] | None
        :return:
            An :class:`ObservedWatch` object instance representing
            a watch.
        r¨   rM   N)r‰   r   rŸ   rŽ   r†   rT   rN   Úis_aliver¦   r”   r‹   r‘   )r   rž   r    r!   r   r/   r“   s          r   ÚschedulezBaseObserver.schedule  s®   € ðD �Z‰Zñ 
	%Ü! $°)È,ÔWˆEØ×'Ñ'¨°uÔ=ð ˜D×3Ñ3Ñ3Ø×-Ñ-¨d×.>Ñ.>ÀÈtÏ|É|ÐjvÐ-Ów�Ø—=‘=”?Ø—M‘M”OØ×!Ñ! 'Ô*Ø�M‰M×Ñ˜eÔ$÷
	%ð ˆ÷
	%ð ˆús   �B$B;Â;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_watch=  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_watchO  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.unschedulea  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)zCUnschedules all watches and detaches all associated event handlers.N)r‰   rŒ   rš   r›   r‹   r$   s    r   Úunschedule_allzBaseObserver.unschedule_allp  sJ   € à�Z‰Zñ 	"Ø�N‰N× Ñ Ô"Ø× Ñ Ô"Ø�M‰M×ÑÔ!÷	"÷ 	"ñ 	"ús   �AAÁA$c                ó$   — | j                  «        y r   )r³   r$   s    r   Úon_thread_stopzBaseObserver.on_thread_stopw  s   € Ø×ÑÕr   c                óF  — |j                  d¬«      }|t        j                  u ry |\  }}| j                  5  | j                  |   j                  «       D ]%  }|| j                  |   v sŒ|j                  |«       Œ' 	 d d d «       |j                  «        y # 1 sw Y   ŒxY w)NT)Úblock)Úgetrp   r{   r‰   rŒ   r¥   ÚdispatchÚ	task_done)r   rT   Úentryr]   r/   Úhandlers         r   r~   zBaseObserver.dispatch_eventsz  s˜   € Ø—‘ d�Ó+ˆØ”O×.Ñ.Ñ.Øà‰ˆˆuà�Z‰Zñ 	,ð  Ÿ>™>¨%Ñ0×5Ñ5Ó7ò ,�Ø˜dŸn™n¨UÑ3Ò3Ø×$Ñ$ UÕ+ñ,÷		,ð 	×ÑÕ÷	,ð 	,ús   ·2BÁ*BÂB )r�   ztype[EventEmitter]rN   rg   rG   rh   )r“   rL   rG   rh   rk   )rž   r
   r/   r   rG   rh   )r/   r   rG   rh   )rG   zset[EventEmitter])
rž   r
   r    r   r!   rE   r   rF   rG   r   r�   )r   r   r   r   r‚   r"   r”   r˜   r›   rŸ   r¡   rJ   r£   r¦   r«   r­   r¯   r±   r³   rµ   r~   rm   rn   s   @r   r„   r„   Ú   s�   ø„ ÙàNf÷ Hó$óó(ó1ó"ð òó ðõð  Ø;?ñ-à-ð-ð ð-ð
 ð-ð 9ð-ð 
ó-ó^>ó$8ó$(ó"ó÷ r   r„   )Ú
__future__r   rv   rx   r‡   Úcollectionsr   Úpathlibr   Útypingr   Úwatchdog.utilsr   Úwatchdog.utils.bricksr   Úwatchdog.eventsr	   r
   rl   r‚   r   r   rL   rp   r„   r   r   r   ú<module>rÄ      sv   ðÝ "ã Û Û Ý #Ý Ý  å %Ý 2áßGàÐ ØÐ ôÐ!ô ÷6rñ 6rôtG,�:ô G,ôT6�jô 6ôrn �?õ n r   