Ë
    äÞËj=  ã                  óì  — d Z ddlmZ ddlZddlZddlZddlmZm	Z	 ddl
mZ ddlmZ dZdZd	Zd
ZdZdZ ed¬«       G d„ d«      «       Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ d e«      Z G d!„ d"e«      Z G d#„ d$e«      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#d/„ Z$d0„ Z%y)1um  :module: watchdog.events
:synopsis: File system events and event handlers.
:author: yesudeep@google.com (Yesudeep Mangalapilly)
:author: contact@tiger-222.fr (MickaÃ«l Schoentgen)

Event Classes
-------------
.. autoclass:: FileSystemEvent
   :members:
   :show-inheritance:
   :inherited-members:

.. autoclass:: FileSystemMovedEvent
   :members:
   :show-inheritance:

.. autoclass:: FileMovedEvent
   :members:
   :show-inheritance:

.. autoclass:: DirMovedEvent
   :members:
   :show-inheritance:

.. autoclass:: FileModifiedEvent
   :members:
   :show-inheritance:

.. autoclass:: DirModifiedEvent
   :members:
   :show-inheritance:

.. autoclass:: FileCreatedEvent
   :members:
   :show-inheritance:

.. autoclass:: FileClosedEvent
   :members:
   :show-inheritance:

.. autoclass:: FileOpenedEvent
   :members:
   :show-inheritance:

.. autoclass:: DirCreatedEvent
   :members:
   :show-inheritance:

.. autoclass:: FileDeletedEvent
   :members:
   :show-inheritance:

.. autoclass:: DirDeletedEvent
   :members:
   :show-inheritance:


Event Handler Classes
---------------------
.. autoclass:: FileSystemEventHandler
   :members:
   :show-inheritance:

.. autoclass:: PatternMatchingEventHandler
   :members:
   :show-inheritance:

.. autoclass:: RegexMatchingEventHandler
   :members:
   :show-inheritance:

.. autoclass:: LoggingEventHandler
   :members:
   :show-inheritance:

é    )ÚannotationsN)Ú	dataclassÚfield)ÚOptional)Úmatch_any_pathsÚmovedÚdeletedÚcreatedÚmodifiedÚclosedÚopenedT)Úunsafe_hashc                  ó„   — e Zd ZU dZded<   dZded<    edd¬«      Zded<    edd¬«      Zd	ed
<   	  ed¬«      Z	d	ed<   y)ÚFileSystemEventa  Immutable type that represents a file system event that is triggered
    when a change occurs on the monitored file system.

    All FileSystemEvent objects are required to be immutable and hence
    can be used as keys in dictionaries or be added to sets.
    ÚstrÚsrc_pathÚ Ú	dest_pathF)ÚdefaultÚinitÚ
event_typeÚboolÚis_directory)r   Úis_syntheticN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r   r   r   r   © ó    úL/var/www/photos/backend/venv/lib/python3.12/site-packages/watchdog/events.pyr   r   o   sP   … ñð ƒMØ€IˆsÓÙ B¨UÔ3€J�Ó3Ù u°5Ô9€L�$Ó9ðñ
  uÔ-€L�$Ô-r!   r   c                  ó   — e Zd ZdZeZy)ÚFileSystemMovedEventz@File system event representing any kind of file system movement.N)r   r   r   r   ÚEVENT_TYPE_MOVEDr   r    r!   r"   r$   r$   …   s
   „ ÙJà!�Jr!   r$   c                  ó   — e Zd ZdZeZy)ÚFileDeletedEventz@File system event representing file deletion on the file system.N)r   r   r   r   ÚEVENT_TYPE_DELETEDr   r    r!   r"   r'   r'   Ž   ó
   „ ÙJà#�Jr!   r'   c                  ó   — e Zd ZdZeZy)ÚFileModifiedEventzDFile system event representing file modification on the file system.N)r   r   r   r   ÚEVENT_TYPE_MODIFIEDr   r    r!   r"   r+   r+   ”   s
   „ ÙNà$�Jr!   r+   c                  ó   — e Zd ZdZeZy)ÚFileCreatedEventz@File system event representing file creation on the file system.N)r   r   r   r   ÚEVENT_TYPE_CREATEDr   r    r!   r"   r.   r.   š   r)   r!   r.   c                  ó   — e Zd ZdZy)ÚFileMovedEventz@File system event representing file movement on the file system.N)r   r   r   r   r    r!   r"   r1   r1       s   „ ÚJr!   r1   c                  ó   — e Zd ZdZeZy)ÚFileClosedEventú=File system event representing file close on the file system.N)r   r   r   r   ÚEVENT_TYPE_CLOSEDr   r    r!   r"   r3   r3   ¤   ó
   „ ÙGà"�Jr!   r3   c                  ó   — e Zd ZdZeZy)ÚFileOpenedEventr4   N)r   r   r   r   ÚEVENT_TYPE_OPENEDr   r    r!   r"   r8   r8   ª   r6   r!   r8   c                  ó   — e Zd ZdZeZdZy)ÚDirDeletedEventzEFile system event representing directory deletion on the file system.TN)r   r   r   r   r(   r   r   r    r!   r"   r;   r;   ³   ó   „ ÙOà#€JØ�Lr!   r;   c                  ó   — e Zd ZdZeZdZy)ÚDirModifiedEventzIFile system event representing directory modification on the file system.TN)r   r   r   r   r,   r   r   r    r!   r"   r>   r>   º   s   „ ÙSà$€JØ�Lr!   r>   c                  ó   — e Zd ZdZeZdZy)ÚDirCreatedEventzEFile system event representing directory creation on the file system.TN)r   r   r   r   r/   r   r   r    r!   r"   r@   r@   Á   r<   r!   r@   c                  ó   — e Zd ZdZdZy)ÚDirMovedEventzEFile system event representing directory movement on the file system.TN)r   r   r   r   r   r    r!   r"   rB   rB   È   s
   „ ÙOà�Lr!   rB   c                  óP   — e Zd ZdZdd„Zdd„Zdd„Zdd„Zdd„Zdd„Z	dd„Z
dd	„Zy
)ÚFileSystemEventHandlerzBBase file system event handler that you can override methods from.c                ó  — | j                  |«       	 t        | j                  t        | j                  t
        | j                  t        | j                  t        | j                  t        | j                  i|j                     |«       y)úÈDispatches events to the appropriate methods.

        :param event:
            The event object representing the file system event.
        :type event:
            :class:`FileSystemEvent`
        N)Úon_any_eventr/   Ú
on_createdr(   Ú
on_deletedr,   Úon_modifiedr%   Úon_movedr5   Ú	on_closedr9   Ú	on_openedr   ©ÚselfÚevents     r"   ÚdispatchzFileSystemEventHandler.dispatchÑ   sn   € ð 	×Ñ˜%Ô ð	Ü §¡Ü §¡Ü ×!1Ñ!1Ü˜dŸm™mÜ˜tŸ~™~Ü˜tŸ~™~ð	
ð ×
Ñ
ñ	ð "õ	#r!   c                 ó   — y)z³Catch-all event handler.

        :param event:
            The event object representing the file system event.
        :type event:
            :class:`FileSystemEvent`
        Nr    rN   s     r"   rG   z#FileSystemEventHandler.on_any_eventã   ó   � r!   c                 ó   — y)záCalled when a file or a directory is moved or renamed.

        :param event:
            Event representing file/directory movement.
        :type event:
            :class:`DirMovedEvent` or :class:`FileMovedEvent`
        Nr    rN   s     r"   rK   zFileSystemEventHandler.on_movedì   rS   r!   c                 ó   — y)zÚCalled when a file or directory is created.

        :param event:
            Event representing file/directory creation.
        :type event:
            :class:`DirCreatedEvent` or :class:`FileCreatedEvent`
        Nr    rN   s     r"   rH   z!FileSystemEventHandler.on_createdõ   rS   r!   c                 ó   — y)zÚCalled when a file or directory is deleted.

        :param event:
            Event representing file/directory deletion.
        :type event:
            :class:`DirDeletedEvent` or :class:`FileDeletedEvent`
        Nr    rN   s     r"   rI   z!FileSystemEventHandler.on_deletedþ   rS   r!   c                 ó   — y)záCalled when a file or directory is modified.

        :param event:
            Event representing file/directory modification.
        :type event:
            :class:`DirModifiedEvent` or :class:`FileModifiedEvent`
        Nr    rN   s     r"   rJ   z"FileSystemEventHandler.on_modified  rS   r!   c                 ó   — y)z·Called when a file opened for writing is closed.

        :param event:
            Event representing file closing.
        :type event:
            :class:`FileClosedEvent`
        Nr    rN   s     r"   rL   z FileSystemEventHandler.on_closed  rS   r!   c                 ó   — y)z¤Called when a file is opened.

        :param event:
            Event representing file opening.
        :type event:
            :class:`FileOpenedEvent`
        Nr    rN   s     r"   rM   z FileSystemEventHandler.on_opened  rS   r!   N©rP   r   ÚreturnÚNone)r   r   r   r   rQ   rG   rK   rH   rI   rJ   rL   rM   r    r!   r"   rD   rD   Î   s-   „ ÙLó#ó$óóóóóôr!   rD   c                  óx   ‡ — e Zd ZdZ	 	 	 	 dˆ fd„	Zed„ «       Zed„ «       Zed„ «       Zed„ «       Z	d	ˆ fd„Z
ˆ xZS )
ÚPatternMatchingEventHandlerzË
    Matches given patterns with file paths associated with occurring events.
    Uses pathlib's `PurePath.match()` method. `patterns` and `ignore_patterns`
    are expected to be a list of strings.
    c                óZ   •— t         ‰| �  «        || _        || _        || _        || _        y ©N)ÚsuperÚ__init__Ú	_patternsÚ_ignore_patternsÚ_ignore_directoriesÚ_case_sensitive)rO   ÚpatternsÚignore_patternsÚignore_directoriesÚcase_sensitiveÚ	__class__s        €r"   rb   z$PatternMatchingEventHandler.__init__*  s/   ø€ ô 	‰ÑÔà!ˆŒØ /ˆÔØ#5ˆÔ Ø-ˆÕr!   c                ó   — | j                   S )zD(Read-only)
        Patterns to allow matching event paths.
        )rc   ©rO   s    r"   rg   z$PatternMatchingEventHandler.patterns8  s   € ð
 �~‰~Ðr!   c                ó   — | j                   S )zE(Read-only)
        Patterns to ignore matching event paths.
        )rd   rm   s    r"   rh   z+PatternMatchingEventHandler.ignore_patterns?  s   € ð
 ×$Ñ$Ð$r!   c                ó   — | j                   S ©z\(Read-only)
        ``True`` if directories should be ignored; ``False`` otherwise.
        ©re   rm   s    r"   ri   z.PatternMatchingEventHandler.ignore_directoriesF  ó   € ð
 ×'Ñ'Ð'r!   c                ó   — | j                   S ©zu(Read-only)
        ``True`` if path names should be matched sensitive to case; ``False``
        otherwise.
        ©rf   rm   s    r"   rj   z*PatternMatchingEventHandler.case_sensitiveM  ó   € ð ×#Ñ#Ð#r!   c                óž  •— | j                   r|j                  ryg }t        |d«      r.|j                  t	        j
                  |j                  «      «       |j                  r.|j                  t	        j
                  |j                  «      «       t        || j                  | j                  | j                  ¬«      rt        ‰| �5  |«       yy)rF   Nr   )Úincluded_patternsÚexcluded_patternsrj   )ri   r   ÚhasattrÚappendÚosÚfsdecoder   r   r   rg   rh   rj   ra   rQ   ©rO   rP   Úpathsrk   s      €r"   rQ   z$PatternMatchingEventHandler.dispatchU  s™   ø€ ð ×"Ò" u×'9Ò'9ØàˆÜ�5˜+Ô&Ø�L‰LœŸ™ U§_¡_Ó5Ô6Ø�>Š>Ø�L‰LœŸ™ U§^¡^Ó4Ô5äØØ"Ÿm™mØ"×2Ñ2Ø×.Ñ.õ	
ô ‰GÑ˜UÕ#ð
r!   ©NNFFrZ   )r   r   r   r   rb   Úpropertyrg   rh   ri   rj   rQ   Ú__classcell__©rk   s   @r"   r^   r^   #  su   ø„ ñð ØØ Øõ.ð ñó ðð ñ%ó ð%ð ñ(ó ð(ð ñ$ó ð$÷$ñ $r!   r^   c                  óx   ‡ — e Zd ZdZ	 	 	 	 dˆ fd„	Zed„ «       Zed„ «       Zed„ «       Zed„ «       Z	d	ˆ fd„Z
ˆ xZS )
ÚRegexMatchingEventHandlerzk
    Matches given regexes with file paths associated with occurring events.
    Uses the `re` module.
    c                ó"  •— t         ‰| �  «        |€dg}nt        |t        «      r|g}|€g }|rQ|D �cg c]  }t	        j
                  |«      ‘Œ c}| _        |D �cg c]  }t	        j
                  |«      ‘Œ c}| _        nn|D �cg c]&  }t	        j
                  |t        j                  «      ‘Œ( c}| _        |D �cg c]&  }t	        j
                  |t        j                  «      ‘Œ( c}| _        || _	        || _
        y c c}w c c}w c c}w c c}w )Nz.*)ra   rb   Ú
isinstancer   ÚreÚcompileÚ_regexesÚ_ignore_regexesÚ
IGNORECASEre   rf   )rO   ÚregexesÚignore_regexesri   rj   Úrrk   s         €r"   rb   z"RegexMatchingEventHandler.__init__u  sÑ   ø€ ô 	‰ÑÔàˆ?Ø�g‰GÜ˜¤Ô%Ø�iˆGØÐ!ØˆNÙØ4;Ö<¨qœRŸZ™Z¨�]Ò<ˆDŒMØ;IÖ#J°a¤B§J¡J¨q¥MÒ#JˆDÕ àCJÖK¸aœRŸZ™Z¨¬2¯=©=Õ9ÒKˆDŒMØJXÖ#YÀQ¤B§J¡J¨q´"·-±-Õ$@Ò#YˆDÔ Ø#5ˆÔ Ø-ˆÕùò =ùÚ#JùâKùÚ#Ys   ³C=ÁDÂ+DÂ;+Dc                ó   — | j                   S )zC(Read-only)
        Regexes to allow matching event paths.
        )rŠ   rm   s    r"   r�   z!RegexMatchingEventHandler.regexes�  s   € ð
 �}‰}Ðr!   c                ó   — | j                   S )zD(Read-only)
        Regexes to ignore matching event paths.
        )r‹   rm   s    r"   rŽ   z(RegexMatchingEventHandler.ignore_regexes”  s   € ð
 ×#Ñ#Ð#r!   c                ó   — | j                   S rp   rq   rm   s    r"   ri   z,RegexMatchingEventHandler.ignore_directories›  rr   r!   c                ó   — | j                   S rt   ru   rm   s    r"   rj   z(RegexMatchingEventHandler.case_sensitive¢  rv   r!   c                óÀ  •‡— | j                   r|j                  ryg Št        |d«      r.‰j                  t	        j
                  |j                  «      «       |j                  r.‰j                  t	        j
                  |j                  «      «       t        ˆfd„| j                  D «       «      ryt        ˆfd„| j                  D «       «      rt        ‰| �1  |«       yy)rF   Nr   c              3  óN   •K  — | ]  }‰D ]  }|j                  |«      –— Œ Œ y ­wr`   ©Úmatch©Ú.0r�   Úpr   s      €r"   ú	<genexpr>z5RegexMatchingEventHandler.dispatch.<locals>.<genexpr>»  s%   øè ø€ ÒF˜aÀÒF¸1ˆq�w‰w�q�zÐFˆzÑFùó   ƒ"%c              3  óN   •K  — | ]  }‰D ]  }|j                  |«      –— Œ Œ y ­wr`   r–   r˜   s      €r"   r›   z5RegexMatchingEventHandler.dispatch.<locals>.<genexpr>¾  s%   øè ø€ Ò?˜a¸Ò?°Aˆq�w‰w�q�zÐ?ˆzÑ?ùrœ   )ri   r   rz   r{   r|   r}   r   r   ÚanyrŽ   r�   ra   rQ   r~   s     @€r"   rQ   z"RegexMatchingEventHandler.dispatchª  s�   ù€ ð ×"Ò" u×'9Ò'9ØàˆÜ�5˜+Ô&Ø�L‰LœŸ™ U§_¡_Ó5Ô6Ø�>Š>Ø�L‰LœŸ™ U§^¡^Ó4Ô5äÓF 4×#6Ñ#6ÔFÔFØäÓ? 4§<¡<Ô?Ô?Ü‰GÑ˜UÕ#ð @r!   r€   rZ   )r   r   r   r   rb   r�   r�   rŽ   ri   rj   rQ   r‚   rƒ   s   @r"   r…   r…   o  su   ø„ ñð ØØ Øõ.ð0 ñó ðð ñ$ó ð$ð ñ(ó ð(ð ñ$ó ð$÷$ñ $r!   r…   c                  ón   ‡ — e Zd ZdZd	d
ˆ fd„Zdˆ fd„Zdˆ fd„Zdˆ fd„Zdˆ fd„Zdˆ fd„Z	dˆ fd„Z
ˆ xZS )ÚLoggingEventHandlerzLogs all the events captured.c                óT   •— t         ‰| �  «        |xs t        j                  | _        y r`   )ra   rb   ÚloggingÚrootÚlogger)rO   r¤   rk   s     €r"   rb   zLoggingEventHandler.__init__Å  s   ø€ Ü‰ÑÔØÒ,¤§¡ˆ�r!   c                ó¨   •— t         ‰| �  |«       |j                  rdnd}| j                  j	                  d||j
                  |j                  «       y )NÚ	directoryÚfilezMoved %s: from %s to %s)ra   rK   r   r¤   Úinfor   r   ©rO   rP   Úwhatrk   s      €r"   rK   zLoggingEventHandler.on_movedÉ  s@   ø€ Ü‰Ñ˜Ôà#×0Ò0‰{°fˆØ�‰×ÑÐ2°D¸%¿.¹.È%Ï/É/ÕZr!   c                ó’   •— t         ‰| �  |«       |j                  rdnd}| j                  j	                  d||j
                  «       y )Nr¦   r§   zCreated %s: %s)ra   rH   r   r¤   r¨   r   r©   s      €r"   rH   zLoggingEventHandler.on_createdÏ  ó:   ø€ Ü‰Ñ˜5Ô!à#×0Ò0‰{°fˆØ�‰×ÑÐ)¨4°·±Õ@r!   c                ó’   •— t         ‰| �  |«       |j                  rdnd}| j                  j	                  d||j
                  «       y )Nr¦   r§   zDeleted %s: %s)ra   rI   r   r¤   r¨   r   r©   s      €r"   rI   zLoggingEventHandler.on_deletedÕ  r¬   r!   c                ó’   •— t         ‰| �  |«       |j                  rdnd}| j                  j	                  d||j
                  «       y )Nr¦   r§   zModified %s: %s)ra   rJ   r   r¤   r¨   r   r©   s      €r"   rJ   zLoggingEventHandler.on_modifiedÛ  s:   ø€ Ü‰Ñ˜EÔ"à#×0Ò0‰{°fˆØ�‰×ÑÐ*¨D°%·.±.ÕAr!   c                óp   •— t         ‰| �  |«       | j                  j                  d|j                  «       y )NzClosed file: %s)ra   rL   r¤   r¨   r   ©rO   rP   rk   s     €r"   rL   zLoggingEventHandler.on_closedá  ó)   ø€ Ü‰Ñ˜%Ô à�‰×ÑÐ*¨E¯N©NÕ;r!   c                óp   •— t         ‰| �  |«       | j                  j                  d|j                  «       y )NzOpened file: %s)ra   rM   r¤   r¨   r   r°   s     €r"   rM   zLoggingEventHandler.on_openedæ  r±   r!   r`   )r¤   zOptional[logging.Logger]r[   r\   rZ   )r   r   r   r   rb   rK   rH   rI   rJ   rL   rM   r‚   rƒ   s   @r"   r    r    Â  s2   ø„ Ù'ö-õ[õAõAõBõ<÷
<ñ <r!   r    c              #  ó|  K  — t        j                  |«      D ]   \  }}}|D ]H  }t         j                  j                  ||«      }| r|j	                  || «      nd}t        ||d¬«      –— ŒJ |D ]H  }t         j                  j                  ||«      }| r|j	                  || «      nd}t        ||d¬«      –— ŒJ Œ¢ y­w)aä  Generates an event list of :class:`DirMovedEvent` and
    :class:`FileMovedEvent` objects for all the files and directories within
    the given moved directory that were moved along with the directory.

    :param src_dir_path:
        The source path of the moved directory.
    :param dest_dir_path:
        The destination path of the moved directory.
    :returns:
        An iterable of file system events of type :class:`DirMovedEvent` and
        :class:`FileMovedEvent`.
    r   T©r   N)r|   ÚwalkÚpathÚjoinÚreplacerB   r1   )	Úsrc_dir_pathÚdest_dir_pathr£   ÚdirectoriesÚ	filenamesr¦   Ú	full_pathÚrenamed_pathÚfilenames	            r"   Úgenerate_sub_moved_eventsrÀ   ì  sÁ   è ø€ ô )+¯©°Ó(>ò MÑ$ˆˆk˜9Ø$ò 	LˆIÜŸ™Ÿ™ T¨9Ó5ˆIÙMY˜9×,Ñ,¨]¸LÔIÐ_aˆLÜ ¨iÀdÔKÓKð	Lð "ò 	MˆHÜŸ™Ÿ™ T¨8Ó4ˆIÙMY˜9×,Ñ,¨]¸LÔIÐ_aˆLÜ  ¨yÀtÔLÓLñ	MñMùs   ‚B:B<c              #  ó  K  — t        j                  | «      D ]n  \  }}}|D ]/  }t        t         j                  j	                  ||«      d¬«      –— Œ1 |D ]/  }t        t         j                  j	                  ||«      d¬«      –— Œ1 Œp y­w)aŸ  Generates an event list of :class:`DirCreatedEvent` and
    :class:`FileCreatedEvent` objects for all the files and directories within
    the given moved directory that were moved along with the directory.

    :param src_dir_path:
        The source path of the created directory.
    :returns:
        An iterable of file system events of type :class:`DirCreatedEvent` and
        :class:`FileCreatedEvent`.
    Tr´   N)r|   rµ   r@   r¶   r·   r.   )r¹   r£   r»   r¼   r¦   r¿   s         r"   Úgenerate_sub_created_eventsrÂ     sƒ   è ø€ ô )+¯©°Ó(=ò TÑ$ˆˆk˜9Ø$ò 	TˆIÜ!¤"§'¡'§,¡,¨t°YÓ"?ÈdÔSÓSð	Tà!ò 	TˆHÜ"¤2§7¡7§<¡<°°hÓ#?ÈdÔSÓSñ	TñTùs   ‚BB
)&r   Ú
__future__r   r¢   Úos.pathr|   rˆ   Údataclassesr   r   Útypingr   Úwatchdog.utils.patternsr   r%   r(   r/   r,   r5   r9   r   r$   r'   r+   r.   r1   r3   r8   r;   r>   r@   rB   rD   r^   r…   r    rÀ   rÂ   r    r!   r"   ú<module>rÈ      s4  ðñ KõZ #ã Û Û 	ß (Ý å 3àÐ ØÐ ØÐ Ø Ð ØÐ ØÐ ñ �tÔ÷.ð .ó ð.ô*"˜?ô "ô$�ô $ô%˜ô %ô$�ô $ôKÐ)ô Kô#�oô #ô#�oô #ô�oô ô�ô ô�oô ôÐ(ô ÷Rñ RôjI$Ð"8ô I$ôXP$Ð 6ô P$ôf'<Ð0ô '<òTMó0Tr!   