
    ʆhR                       S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SKJ
r
JrJr  S SKJr  S SKJr  S SKJr  \(       a  S SKJr  \R*                  " S5      r\" \S5      (       a  \" \S	5      (       a  \" \S
5      (       d  S\R0                   3r\" \5      e\R4                  " \\\
\SS9" S	\45      r\R4                  " \\\SS9" S
\45      r\R4                  " \SS9" S\45      r " S S5      r\" S \R>                  \R@                  \RB                  \RD                  \RF                  \RH                  \RJ                  \RL                  \RN                  \RP                  \RR                  /5      r* " S S\RV                  5      r,\RZ                  " \,5      r.Sr/\/\.S-   -  r0 " S S5      r1 " S S5      r2g)    )annotationsN)c_char_pc_intc_uint32)reduce)TYPE_CHECKING)UnsupportedLibcError)	Generatorinotify_initinotify_add_watchinotify_rm_watchz Unsupported libc version found: T)	use_errnoc                      \ rS rSrSrSrSrSrSrSr	Sr
S	rS
rSrSrSr\
\-  rSrSrSrSrSrSrSrSrSr\" S \\\\\\	\
\\\\\/5      rSrSrSrg)InotifyConstants!                      @         i   i      i    i @  i   i   i   i   i    i   @l        c                
    X-  $ N xys     T/opt/services/DDDS/venv/lib/python3.13/site-packages/watchdog/observers/inotify_c.py<lambda>InotifyConstants.<lambda>B   s    QU    r   N)__name__
__module____qualname____firstlineno__	IN_ACCESS	IN_MODIFY	IN_ATTRIBIN_CLOSE_WRITEIN_CLOSE_NOWRITEIN_OPENIN_MOVED_FROMIN_MOVED_TO	IN_CREATE	IN_DELETEIN_DELETE_SELFIN_MOVE_SELFIN_MOVE
IN_UNMOUNTIN_Q_OVERFLOW
IN_IGNORED
IN_ONLYDIRIN_DONT_FOLLOWIN_EXCL_UNLINKIN_MASK_ADDIN_ISDIR
IN_ONESHOTr   IN_ALL_EVENTS
IN_CLOEXECIN_NONBLOCK__static_attributes__r   r%   r"   r   r   !   s    IIIN!GMKIINL k)G JMJ JNNKHJ 	
M& JKr%   r   c                
    X-  $ r   r   r   s     r"   r#   r#   Z   s    r%   c                  :    \ rS rSrSrS\4S\4S\4S\4S\44rSr	g	)
InotifyEventStructk   a  Structure representation of the inotify_event structure
(used in buffer size calculations)::

    struct inotify_event {
        __s32 wd;            /* watch descriptor */
        __u32 mask;          /* watch mask */
        __u32 cookie;        /* cookie to synchronize two events */
        __u32 len;           /* length (including nulls) of name */
        char  name[0];       /* stub for possible name */
    };
wdmaskcookielennamer   N)
r&   r'   r(   r)   __doc__r   r   r   _fields_rC   r   r%   r"   rF   rF   k   s7    
 
u		8		Hr%   rF   r   r   c                     \ rS rSrSrSSS.SS jjr\SS j5       r\SS j5       r\SS	 j5       r	\SS
 j5       r
SS jrSS jrSS jrS S jrS S jrSS jr\S.S!S jjrSS jrS"S jrS#S jr\SS j5       r\S$S j5       rSrg)%Inotify   zLinux inotify(7) API wrapper class.

:param path:
    The directory path for which we want an inotify object.
:type path:
    :class:`bytes`
:param recursive:
    ``True`` if subdirectories should be monitored; ``False`` otherwise.
FN)	recursive
event_maskc               N  ^  [        5       nUS:X  a  [        R                  5         UT l        [        R
                  " 5       T l        ST l        ST l        [        R                  " 5       u  T l        T l        [        [        S5      (       a  [        R                  " 5       T l        T R                   R#                  T R                  [        R$                  5        T R                   R#                  T R                  [        R$                  5        SU 4S jjnUT l        OSU 4S jjnUT l        0 T l        0 T l        UT l        Uc  [.        nUT l        UT l        [        R4                  R7                  U5      (       a  T R9                  XUS9  OT R;                  X5        0 T l        g )	NFTpollc                 ^   > [        U 4S jT R                  R                  5        5       5      $ )Nc              3  F   >#    U  H  u  pUTR                   :H  v   M     g 7fr   _inotify_fd).0fd_selfs      r"   	<genexpr>4Inotify.__init__.<locals>.do_poll.<locals>.<genexpr>   s      S?Reb2!1!11?Rs   !)any_pollerrV   r^   s   r"   do_poll!Inotify.__init__.<locals>.do_poll   s!    St||?P?P?RSSSr%   c                    > [         R                   " TR                  TR                  // / 5      n TR                  U S   ;   $ Nr   )selectrZ   _kill_r)resultr^   s    r"   	do_select#Inotify.__init__.<locals>.do_select   s9    (8(8$,,'GRP''6!944r%   )rR   returnbool)r   rP   _raise_errorrZ   	threadingLock_lock_closed_is_readingospiperi   _kill_whasattrrh   rV   rb   registerPOLLIN_check_inotify_fd_wd_for_path_path_for_wd_pathWATCHDOG_ALL_EVENTS_event_mask_is_recursivepathisdir_add_dir_watch
_add_watch_moved_from_events)r^   r   rR   rS   
inotify_fdrd   rk   s   `      r"   __init__Inotify.__init__   s:   !^
  "%^^%
%'WWY"dl 66""!;;=DLLL!!$"2"2FMMBLL!!$,,>T &-D"5 &/D" /1.0
,J%&77==IFOOD-;=r%   c                    U R                   $ )z)The event mask for this inotify instance.)r   rc   s    r"   rS   Inotify.event_mask        r%   c                    U R                   $ )z.The path associated with the inotify instance.)r   rc   s    r"   r   Inotify.path   s     zzr%   c                    U R                   $ )z0Whether we are watching directories recursively.)r   rc   s    r"   is_recursiveInotify.is_recursive   s     !!!r%   c                    U R                   $ )z9The file descriptor associated with the inotify instance.rY   rc   s    r"   r\   
Inotify.fd   r   r%   c                    0 U l         g)z)Clear cached records of MOVED_FROM eventsN)r   rc   s    r"   clear_move_recordsInotify.clear_move_records   s
    "$r%   c                ~    UR                   U R                  ;   a#  U R                  UR                      R                  $ g)zThe source path corresponding to the given MOVED_TO event.

If the source path is outside the monitored directories, None
is returned instead.
N)rJ   r   src_path)r^   destination_events     r"   source_for_moveInotify.source_for_move   s9     ##t'>'>>**+<+C+CDMMMr%   c                4    XR                   UR                  '   g)zMSave this event as the source event for future MOVED_TO events to
reference.
N)r   rJ   )r^   events     r"   remember_move_from_event Inotify.remember_move_from_event   s     16-r%   c                    U R                      U R                  XR                  5        SSS5        g! , (       d  f       g= f)zMAdds a watch for the given path.

:param path:
    Path to begin monitoring.
N)rs   r   r   )r^   r   s     r"   	add_watchInotify.add_watch   s'     ZZOOD"2"23 ZZs	   2
A c                    U R                      U R                  R                  U5      nU R                  U	 [	        U R
                  U5      S:X  a  [        R                  5         SSS5        g! , (       d  f       g= f)zgRemoves a watch for the given path.

:param path:
    Path string for which the watch will be removed.
rU   N)rs   r}   popr~   r   rZ   rP   rp   )r^   r   rH   s      r"   remove_watchInotify.remove_watch   sZ     ZZ""&&t,B!!"% 0 0"5;$$&	 ZZs   AA--
A;c                   U R                      U R                  (       d  SU l        U R                  U R                  ;   a/  U R                  U R                     n[	        U R
                  U5        U R                  (       a"  [        R                  " U R                  S5        OU R                  5         SSS5        g! , (       d  f       g= f)z?Closes the inotify instance and removes all associated watches.T   !N)rs   rt   r   r}   r   rZ   ru   rv   writerx   _close_resources)r^   rH   s     r"   closeInotify.close   s    ZZ<<#::!2!22**4::6B$T%5%5r:## HHT\\40))+ ZZs   B%B;;
C	)event_buffer_sizec          	       ^  SU 4S jjnSn  T R                      T R                  (       a  / sSSS5        $ ST l        SSS5        T R                  5       (       a!  [        R
                  " T R                  U5      nT R                      ST l        T R                  (       a  T R                  5         / sSSS5        $  SSS5         T R                      / n[        R                  U5       GH  u  pgpUS:X  a  M  T R                  U   n
U	(       a  [        R                  R!                  X5      OU
n[#        XgXU5      nUR$                  (       a  T R'                  U5        GOuUR(                  (       Gac  T R+                  U5      nUT R,                  ;   Ga  T R,                  U   nT R,                  U	 UT R,                  UR.                  '   UR.                  T R                  U'   T R0                  (       a  T R,                  R3                  5        H  nUR5                  U[        R                  R6                  R9                  5       -   5      (       d  MD  T R,                  R;                  U5      nUR=                  XR.                  5      nUT R,                  U'   UT R                  U'   M     [        R                  R!                  X5      n[#        XgXU5      nUR>                  (       a;  T R                  R;                  U5      nT R,                  U   U:X  a  T R,                  U	 URA                  U5        T R0                  (       d  GM]  URB                  (       d  GMq  URD                  (       d  GM   T RG                  UT RH                  5        URK                  U" U5      5        GM     SSS5        U$ ! , (       d  f       GN{= f! , (       d  f       GN= f! [         aP  nUR                  [        R                  :X  a   SnAGM  UR                  [        R                  :X  a  / s SnA$ e SnAff = f! [         a     GMW  f = f! , (       d  f       W$ = f)z*Reads events from inotify and yields them.c           
       > / n[         R                  " U 5       GH/  u  p#nU H  n[        R                  " [        5         [         R
                  R                  X%5      nTR                  UTR                  5      n[        U[        R                  [        R                  -  SUU5      nUR                  U5        S S S 5        M     U H|  n	[         R
                  R                  X)5      nTR                  [         R
                  R                  U5         n
[        U
[        R                  SU	U5      nUR                  U5        M~     GM2     U$ ! , (       d  f       GM=  = frg   )rv   walk
contextlibsuppressOSErrorr   joinr   r   InotifyEventr   r2   r>   appendr}   dirname)r   eventsrootdirnames	filenamesr   	full_pathwd_direfilenamewd_parent_dirr^   s              r"   _recursive_simulate0Inotify.read_events.<locals>._recursive_simulate  s   F-/WWX->)	'G#,,W5$&GGLL$?	!%D<L<L!M(",669I9R9RR#% a( 65  ( !*H "T <I$($5$5bggooi6P$QM$%(22 !A MM!$ !* .?0 M- 65s    A;E
E r%   TNFrU   )r   bytesrn   list[InotifyEvent])&rs   rt   ru   r|   rv   readrZ   r   r   errnoEINTREBADFrP   _parse_event_bufferr~   r   r   r   is_moved_fromr   is_moved_tor   r}   r   r   copy
startswithsepencoder   replace
is_ignoredr   is_directory	is_creater   r   extend)r^   r   r   event_bufferr   
event_listrH   rI   rJ   rL   wd_pathr   inotify_eventmove_src_pathmoved_wdr   _move_to_pathr   s   `                 r"   read_eventsInotify.read_events  sh   	8 ZZ||!  Z (,D$	   ))++#%774+;+;=N#OLZZ',D$||--/!  Z $   ZZJ*1*E*El*S&&8++B/:>277<<6G ,RvX N ..11-@"...$($8$8$GM$(9(99#'#4#4]#C --m<DL))-*@*@A6C6L6L))(3,,)-):):)?)?)A#(#3#3MBGGKKDVDVDX4X#Y#Y/3/@/@/D/DU/KH49MM-QgQg4hMGOD$5$5m$DBOD$5$5h$? *B  "ww||G:H$06$RM ++,,004D((."4 --d3!!-0$$$)C)C)CH_H_H_!$2B2BC %%&9(&CD_ +T f Y  Z  Z  77ekk)77ekk)Ip # ! !] Zf s   O N2	O N2A
O *O2	O =O E<QC0QQQ0P3Q2
O<O 
OO O 
P0 P+P+$P0*P++P03
Q=QQQ
Qc                    [         R                  " U R                  5        [         R                  " U R                  5        [         R                  " U R                  5        g r   )rv   r   rZ   ri   rx   rc   s    r"   r   Inotify._close_resources  s4    
!!"

r%   c                  [         R                  R                  U5      (       d=  [        [        R
                  [         R                  " [        R
                  5      U5      eU R                  X5        U(       a  [         R                  " U5       He  u  pEnU HY  n[         R                  R                  XG5      n[         R                  R                  U5      (       a  MH  U R                  X5        M[     Mg     gg)zAdds a watch (optionally recursively) for the given directory path
to monitor events specified by the mask.

:param path:
    Path to monitor
:param recursive:
    ``True`` to monitor recursively.
:param mask:
    Event bit mask.
N)rv   r   r   r   r   ENOTDIRstrerrorr   r   r   islink)	r^   r   rI   rR   r   r   r]   r   r   s	            r"   r   Inotify._add_dir_watch  s     ww}}T""%--U]])CTJJ#%'WWT]!'G "T ;Iww~~i00 OOI4	  ( &3 r%   c                    [        U R                  X5      nUS:X  a  [        R                  5         X0R                  U'   XR
                  U'   U$ )zAdds a watch for the given path to monitor events specified by the
mask.

:param path:
    Path to monitor
:param mask:
    Event bit mask.
rU   )r   rZ   rP   rp   r}   r~   )r^   r   rI   rH   s       r"   r   Inotify._add_watch  sJ     t//<8  ""$$ $"	r%   c                 N   [         R                  " 5       n U [        R                  :X  a  [	        [        R                  S5      eU [        R
                  :X  a  [	        [        R
                  S5      eU [        R                  :w  a   [	        U [        R                  " U 5      5      eg)z#Raises errors for inotify failures.zinotify watch limit reachedzinotify instance limit reachedN)	ctypes	get_errnor   ENOSPCr   EMFILEEACCESrv   r   )errs    r"   rp   Inotify._raise_error  su      %,,%,,(EFF%,,%,,(HII%,,#r{{3/00 r%   c              #     #    SnUS-   [        U 5      ::  aY  [        R                  " SX5      u  p#pEXS-   US-   U-    R                  S5      nUSU-   -  nX#XF4v   US-   [        U 5      ::  a  MX  gg7f)a#  Parses an event buffer of ``inotify_event`` structs returned by
inotify::

    struct inotify_event {
        __s32 wd;            /* watch descriptor */
        __u32 mask;          /* watch mask */
        __u32 cookie;        /* cookie to synchronize two events */
        __u32 len;           /* length (including nulls) of name */
        char  name[0];       /* stub for possible name */
    };

The ``cookie`` member of this struct is used to pair two related
events, for example, it pairs an IN_MOVED_FROM event with an
IN_MOVED_TO event.
r   r   iIII    N)rK   structunpack_fromrstrip)r   irH   rI   rJ   lengthrL   s          r"   r   Inotify._parse_event_buffer  s     " "fL))'-'9'9&,'R$BfBR&9@@GDfAF((	 "fL))s   A+A1/A1)r|   rt   r   rZ   ru   r   ri   rx   rs   r   r   r~   rb   r}   )r   r   rR   ro   rS   z
int | Nonern   Nonern   intrn   r   rm   )rn   r   )r   r   rn   zbytes | None)r   r   rn   r   )r   r   rn   r   )r   r   rn   r   )r   r   rI   r   rR   ro   rn   r   )r   r   rI   r   rn   r   )r   r   rn   z&Generator[tuple[int, int, int, bytes]])r&   r'   r(   r)   rM   r   propertyrS   r   r   r\   r   r   r   r   r   r   DEFAULT_EVENT_BUFFER_SIZEr   r   r   r   staticmethodrp   r   rC   r   r%   r"   rP   rP      s     :?Y] +>Z       " "    %	64
'," 7P rh5,  1 1 ) )r%   rP   c                     \ rS rSrSrS S jr\S!S j5       r\S"S j5       r\S"S j5       r	\S"S j5       r
\S!S j5       r\S#S	 j5       r\S#S
 j5       r\S#S j5       r\S#S j5       r\S#S j5       r\S#S j5       r\S#S j5       r\S#S j5       r\S#S j5       r\S#S j5       r\S#S j5       r\S#S j5       r\S#S j5       r\S#S j5       r\S#S j5       r\S$S j5       rS%S jrS%S jrS"S jr\S&S j5       r S'S jr!Sr"g)(r   i  zInotify event struct wrapper.

:param wd:
    Watch descriptor
:param mask:
    Event mask
:param cookie:
    Event cookie
:param name:
    Base name of the event source path.
:param src_path:
    Full event source path.
c                @    Xl         X l        X0l        X@l        XPl        g r   )_wd_mask_cookie_name	_src_path)r^   rH   rI   rJ   rL   r   s         r"   r   InotifyEvent.__init__  s    

!r%   c                    U R                   $ r   )r  rc   s    r"   r   InotifyEvent.src_path  s    ~~r%   c                    U R                   $ r   )r  rc   s    r"   rH   InotifyEvent.wd  s    xxr%   c                    U R                   $ r   )r  rc   s    r"   rI   InotifyEvent.mask      zzr%   c                    U R                   $ r   )r  rc   s    r"   rJ   InotifyEvent.cookie  s    ||r%   c                    U R                   $ r   )r  rc   s    r"   rL   InotifyEvent.name  r  r%   c                B    U R                   [        R                  -  S:  $ rg   )r  r   r+   rc   s    r"   	is_modifyInotifyEvent.is_modify      zz,666::r%   c                B    U R                   [        R                  -  S:  $ rg   )r  r   r-   rc   s    r"   is_close_writeInotifyEvent.is_close_write      zz,;;;a??r%   c                B    U R                   [        R                  -  S:  $ rg   )r  r   r.   rc   s    r"   is_close_nowriteInotifyEvent.is_close_nowrite  s    zz,===AAr%   c                B    U R                   [        R                  -  S:  $ rg   )r  r   r/   rc   s    r"   is_openInotifyEvent.is_open
      zz,444q88r%   c                B    U R                   [        R                  -  S:  $ rg   )r  r   r*   rc   s    r"   	is_accessInotifyEvent.is_access  r  r%   c                B    U R                   [        R                  -  S:  $ rg   )r  r   r3   rc   s    r"   	is_deleteInotifyEvent.is_delete  r  r%   c                B    U R                   [        R                  -  S:  $ rg   )r  r   r4   rc   s    r"   is_delete_selfInotifyEvent.is_delete_self  r  r%   c                B    U R                   [        R                  -  S:  $ rg   )r  r   r2   rc   s    r"   r   InotifyEvent.is_create  r  r%   c                B    U R                   [        R                  -  S:  $ rg   )r  r   r0   rc   s    r"   r   InotifyEvent.is_moved_from  s    zz,:::Q>>r%   c                B    U R                   [        R                  -  S:  $ rg   )r  r   r1   rc   s    r"   r   InotifyEvent.is_moved_to"  s    zz,8881<<r%   c                B    U R                   [        R                  -  S:  $ rg   )r  r   r6   rc   s    r"   is_moveInotifyEvent.is_move&  r!  r%   c                B    U R                   [        R                  -  S:  $ rg   )r  r   r5   rc   s    r"   is_move_selfInotifyEvent.is_move_self*  s    zz,999A==r%   c                B    U R                   [        R                  -  S:  $ rg   )r  r   r,   rc   s    r"   	is_attribInotifyEvent.is_attrib.  r  r%   c                B    U R                   [        R                  -  S:  $ rg   )r  r   r9   rc   s    r"   r   InotifyEvent.is_ignored2  s    zz,777!;;r%   c                    U R                   =(       d3    U R                  =(       d     U R                  [        R                  -  S:  $ rg   )r)  r5  r  r   r>   rc   s    r"   r   InotifyEvent.is_directory6  s6    
 ""ed&7&7e4::HXHaHa;ade;eer%   c                t    U R                   U R                  U R                  U R                  U R                  4$ r   )r  r  r  r  r  rc   s    r"   keyInotifyEvent.key=  s'    ~~txxT\\4::MMr%   c                j    [        U[        5      (       d  [        $ U R                  UR                  :H  $ r   
isinstancer   NotImplementedr?  r^   r   s     r"   __eq__InotifyEvent.__eq__A  *    -66!!xx=,,,,r%   c                j    [        U[        5      (       d  [        $ U R                  UR                  :g  $ r   rB  rE  s     r"   __ne__InotifyEvent.__ne__F  rH  r%   c                ,    [        U R                  5      $ r   )hashr?  rc   s    r"   __hash__InotifyEvent.__hash__K  s    DHH~r%   c                    / n[        [        5       HO  nUR                  S5      (       d  M  US;  d  M#  [        [        U5      nX-  (       d  M>  UR	                  U5        MQ     SR                  U5      $ )NIN_>   r6   r@   |)dirr   r   getattrr   r   )rI   maskscc_vals       r"   _get_mask_stringInotifyEvent._get_mask_stringN  s]    %&A||E""q0L'L 0!4<<LLO	 '
 xxr%   c                    S[        U 5      R                   SU R                  < SU R                   SU R	                  U R
                  5       SU R                   S[        R                  " U R                  5      < S3$ )N<z: src_path=z, wd=z, mask=z	, cookie=z, name=>)
typer&   r   rH   rX  rI   rJ   rv   fsdecoderL   rc   s    r"   __repr__InotifyEvent.__repr__X  ss    T
##$K/@dggY O**49956i} M[[+.a1	
r%   )r  r  r  r  r  N)rH   r   rI   r   rJ   r   rL   r   r   r   rn   r   r   r   rm   )rn   z"tuple[bytes, int, int, int, bytes])r   objectrn   ro   )rI   r   rn   str)rn   rb  )#r&   r'   r(   r)   rM   r   r   r   rH   rI   rJ   rL   r  r  r  r  r#  r&  r)  r   r   r   r2  r5  r8  r   r   r?  rF  rJ  rN  r   rX  r_  rC   r   r%   r"   r   r     s   "           ; ; @ @ B B 9 9 ; ; ; ; @ @ ; ; ? ? = = 9 9 > > ; ; < < f f N N-
-
  
r%   r   )3
__future__r   r   r   ctypes.utilr   rv   rh   r   rq   r   r   r   	functoolsr   typingr   watchdog.utilsr	   collections.abcr
   CDLLlibcry   r  error	CFUNCTYPEr   r   r   r   r+   r,   r0   r1   r2   r3   r4   r;   r-   r.   r/   r   	StructurerF   sizeof
EVENT_SIZEDEFAULT_NUM_EVENTSr   rP   r   r   r%   r"   <module>rq     s   "     	    , ,    /){{4t^$$GD:M,N,NV]^bdvVwVw.tzzl;E
u
%%$$UE8XQUVXkmqWrs ##E5(dKM_aeLfg 67MN4 4p """"&&$$""""''''''))   $)) , ]]-.
 .*r/B K) K)\
I
 I
r%   