K iRvddlmZddlZddlZddlZddlZddlZddlZddlZddl Z ddlm Z m Z m Z ddl mZddlmZddlmZerddlmZej*dZeedreed r eed sd ej0Zeeej4e e e e d d efZej4e e e d d efZej4e d defZGddZedej>ej@ejBejDejFejHejJejLejNejPejRg Z*GddejVZ,ejZe,Z.dZ/e/e.dzzZ0GddZ1GddZ2y)) annotationsN)c_char_pc_intc_uint32)reduce) TYPE_CHECKING)UnsupportedLibcError) Generator inotify_initinotify_add_watchinotify_rm_watchz Unsupported libc version found: T) use_errnoceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Ze e zZd ZdZdZdZdZdZdZdZdZedeeeeeee e e e e eg ZdZdZy)InotifyConstants @iii i@iiiii i@lc ||zSNxys b/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/watchdog/observers/inotify_c.pyzInotifyConstants.Bs QUN)__name__ __module__ __qualname__ IN_ACCESS IN_MODIFY IN_ATTRIBIN_CLOSE_WRITEIN_CLOSE_NOWRITEIN_OPEN IN_MOVED_FROM IN_MOVED_TO IN_CREATE IN_DELETEIN_DELETE_SELF IN_MOVE_SELFIN_MOVE IN_UNMOUNT IN_Q_OVERFLOW IN_IGNORED IN_ONLYDIRIN_DONT_FOLLOWIN_EXCL_UNLINK IN_MASK_ADDIN_ISDIR IN_ONESHOTr IN_ALL_EVENTS IN_CLOEXEC IN_NONBLOCKrr#r!rr!sIIIN!GMKIINLk)GJMJJNNKHJ             M&JKr#rc ||zSrrrs r!r"r"Zs Qr#c2eZdZdZdefdefdefdefdeffZy)InotifyEventStructaStructure 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 */ }; wdmaskcookielennameN)r$r%r&__doc__rrr_fields_rr#r!rBrBks7  u  8   Hr#rBrrceZdZdZdddddZeddZeddZeddZedd Z dd Z dd Z dd Z dd Z ddZddZedddZddZd dZd!dZeddZed"dZy)#InotifyaLinux 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@t}|dk(rtj|_t j _d_d_tj\_ _ ttdrtj_j j#jtj$j j#jtj$dfd }|_n dfd }|_i_i_|_|t.}|_|_tj4j7|rj9|||i_yj;||i_y) NFTpollc\tfdjjDS)Nc3BK|]\}}|jk(ywr _inotify_fd).0fd_selfs r! z4Inotify.__init__..do_poll..s Seb!2!1!11Ss)any_pollerrPrXsr!do_pollz!Inotify.__init__..do_polls!St||?P?P?RSSSr#ctjjjggg}j|dvSNr)selectrT_kill_r)resultrXs r! do_selectz#Inotify.__init__..do_selects9(8(8$,,'GRP''6!944r#)rLreturnbool)r rK _raise_errorrT threadingLock_lock_closed _is_readingospipera_kill_whasattrr`rPr[registerPOLLIN_check_inotify_fd _wd_for_path _path_for_wd_pathWATCHDOG_ALL_EVENTS _event_mask _is_recursivepathisdir_add_dir_watch _add_watch_moved_from_events)rXrzrLrM inotify_fdr]rcs` r!__init__zInotify.__init__sD!^    "%^^%  %'WWY" dl 66 "!;;=DL LL ! !$"2"2FMM B LL ! !$,, > T&-D " 5&/D "/1.0  ,J%& 77==    jI  F<> OOD* -;=r#c|jS)z)The event mask for this inotify instance.)rxr\s r!rMzInotify.event_maskr#c|jS)z.The path associated with the inotify instance.)rvr\s r!rzz Inotify.pathszzr#c|jS)z0Whether we are watching directories recursively.)ryr\s r! is_recursivezInotify.is_recursives!!!r#c|jS)z9The file descriptor associated with the inotify instance.rSr\s r!rVz Inotify.fdrr#ci|_y)z)Clear cached records of MOVED_FROM eventsN)r~r\s r!clear_move_recordszInotify.clear_move_recordss "$r#cz|j|jvr#|j|jjSy)zThe source path corresponding to the given MOVED_TO event. If the source path is outside the monitored directories, None is returned instead. N)rEr~src_path)rXdestination_events r!source_for_movezInotify.source_for_moves9  # #t'>'> >**+<+C+CDMM Mr#c6||j|j<y)z]Save this event as the source event for future MOVED_TO events to reference. N)r~rE)rXevents r!remember_move_from_eventz Inotify.remember_move_from_events16 -r#c~|j5|j||jdddy#1swYyxYw)zeAdds a watch for the given path. :param path: Path to begin monitoring. N)rjr}rx)rXrzs r! add_watchzInotify.add_watchs4 ZZ 4 OOD$"2"2 3 4 4 4s3<c|j5|jj|}|j|=t |j |dk(rt jdddy#1swYyxYw)zRemoves a watch for the given path. :param path: Path string for which the watch will be removed. rON)rjrtpoprur rTrKrg)rXrzrCs r! remove_watchzInotify.remove_watchse ZZ '""&&t,B!!"% 0 0"5;$$&  ' ' 's AA,,A5ct|j5|jsd|_|j|jvr/|j|j}t |j ||j r!tj|jdn|jdddy#1swYyxYw)z?Closes the inotify instance and removes all associated watches.T!N) rjrkrvrtr rTrlrmwritero_close_resources)rXrCs r!closez Inotify.closes ZZ ,<<# ::!2!22**4::6B$T%5%5r:##HHT\\40))+ , , ,s BB..B7)event_buffer_sizec dfd }d} j5jr gcdddSd_dddjr t j j |}j5d_jrjgcdddS ddd j5g}tj|D]\}}}} |dk(rj|} | r tjj!| | n| } t#|||| | } | j$rj'| ne| j(rXj+| } | j,vr j,| }j,| =|j,| j.<| j.j|<j0rj,j3D]}|j5| tjj6j9zs>j,j;|}|j=| | j.}|j,|<|j|<tjj!| | } t#|||| | } | j>r:jj;|}j,||k(r j,|=|jA| j0s:| jBsH| jDsV jG| jH|jK||  ddd|S#1swY;xYw#1swYxYw#t$rM}|jtjk(rYd}~|jtjk(rgcYd}~Sd}~wwxYw#t$rYwxYw#1swYSxYw)z*Reads events from inotify and yields them.c g}tj|D],\}}}|D]}tjt5tj j ||} j| j}t|tjtjzd||}|j|ddd|D]|} tj j || } jtj j|} t| tjd| |}|j|~/|S#1swY2xYwr_)rmwalk contextlibsuppressOSErrorrzjoinr}rx InotifyEventrr/r;appendrtdirname) reventsrootdirnames filenamesr full_pathwd_direfilename wd_parent_dirrXs r!_recursive_simulatez0Inotify.read_events.._recursive_simulates7F-/WWX-> %)h ' )G#,,W5 )$&GGLLw$? !%D277<<6G ,RvtX N  ..11-@"..$($8$8$GM$(9(99#'#4#4]#C --mZ  ""  % 6 4 ',"7Prh 5,  1 1))r#rKceZdZdZddZeddZed dZed dZed dZ eddZ ed!dZ ed!d Z ed!d Z ed!d Zed!d Zed!d Zed!dZed!dZed!dZed!dZed!dZed!dZed!dZed!dZed!dZed"dZd#dZd#dZd dZed$dZd%dZ y)&ra Inotify 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. cJ||_||_||_||_||_yr)_wd_mask_cookie_name _src_path)rXrCrDrErGrs r!rzInotifyEvent.__init__s%   !r#c|jSr)rr\s r!rzInotifyEvent.src_paths ~~r#c|jSr)rr\s r!rCzInotifyEvent.wds xxr#c|jSr)rr\s r!rDzInotifyEvent.mask zzr#c|jSr)rr\s r!rEzInotifyEvent.cookies ||r#c|jSr)rr\s r!rGzInotifyEvent.namerr#cB|jtjzdkDSr_)rrr(r\s r! is_modifyzInotifyEvent.is_modifyzz,666::r#cB|jtjzdkDSr_)rrr*r\s r!is_close_writezInotifyEvent.is_close_writezz,;;;a??r#cB|jtjzdkDSr_)rrr+r\s r!is_close_nowritezInotifyEvent.is_close_nowriteszz,===AAr#cB|jtjzdkDSr_)rrr,r\s r!is_openzInotifyEvent.is_open zz,444q88r#cB|jtjzdkDSr_)rrr'r\s r! is_accesszInotifyEvent.is_accessrr#cB|jtjzdkDSr_)rrr0r\s r! is_deletezInotifyEvent.is_deleterr#cB|jtjzdkDSr_)rrr1r\s r!is_delete_selfzInotifyEvent.is_delete_selfrr#cB|jtjzdkDSr_)rrr/r\s r!rzInotifyEvent.is_createrr#cB|jtjzdkDSr_)rrr-r\s r!rzInotifyEvent.is_moved_fromszz,:::Q>>r#cB|jtjzdkDSr_)rrr.r\s r!rzInotifyEvent.is_moved_to"szz,8881<r3r=|)dirrrgetattrrr)rDmaskscc_vals r!_get_mask_stringzInotifyEvent._get_mask_stringNs_%& $A||E"q0L'L 0!4%<LLO  $ xxr#cdt|jd|jd|jd|j |j d|j dtj|jd S)N) typer$rrCr$rDrErmfsdecoderGr\s r!__repr__zInotifyEvent.__repr__XssT ##$K /@dggYO**49956i }M[[+.a 1 r#N) rCrrDrrErrGrrrrerrrrd)rez"tuple[bytes, int, int, int, bytes])robjectrerf)rDrrestr)rer,)!r$r%r&rHrrrrCrDrErGrrrrrrrrrrrr r rrrrrrrr$r*rr#r!rrs ";;@@BB99;;;;@@;;??==99>>;;<<ff NN- -  r#r)3 __future__rrr ctypes.utilrrmr`rrhrrr functoolsrtypingrwatchdog.utilsr collections.abcr CDLLlibcrprerror CFUNCTYPEr r r rr(r)r-r.r/r0r1r8r*r+r,rw StructurerBsizeof EVENT_SIZEDEFAULT_NUM_EVENTSrrKrrr#r!r;s"  ,, /)v{{4t^$GD:M,NV]^bdvVw.tzzl ;E u %%V$F$$UE8XQUVXkmqWrsK#6##E5(dKM_aeLfg6v67MN 44p""""&&$$""""''''''))   $)),V]]- . .*r/BK)K)\ I I r#