
    h                     N   S r SSKrSSKrSSKJrJr  SSKJr   " S S\5      r	S\
4S jrS	\
S
\\   S\
S\
4S jrS	\
S\
SS4S jrS\R                  SS4S jr\R                   R#                  S5      r\(       d  \" S5      e\R(                  R+                  \5      r\" \5        g)z
Very low-level ctypes-based interface to Linux inotify(7).

ctypes and a version of libc which supports inotify system calls are
required.
    N)Anycast)FilePathc                       \ rS rSrSrSrg)INotifyError   zJ
Unify all the possible exceptions that can be raised by the INotify API.
 N)__name__
__module____qualname____firstlineno____doc____static_attributes__r	       ^/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/python/_inotify.pyr   r      s    r   r   returnc                  l    [        [        [        R                  5       5      n U S:  a  [	        S5      eU $ )zG
Create an inotify instance and return the associated file descriptor.
r   zINotify initialization error.)r   intlibcinotify_initr   )fds    r   initr      s1     
c4$$&	'B	Av:;;Ir   r   pathmaskc                     [        [        [        R                  XR	                  5       R
                  U5      5      nUS:  a  [        SU< SU< S35      eU$ )a  
Add a watch for the given path to the inotify file descriptor, and return
the watch descriptor.

@param fd: The file descriptor returned by C{libc.inotify_init}.
@param path: The path to watch via inotify.
@param mask: Bitmask specifying the events that inotify should monitor.
r   zFailed to add watch on 'z' - ())r   r   r   inotify_add_watchasBytesModer   r   )r   r   r   wds       r   addr    #   sS     
c4))".>.>.@.E.EtL	MB	Av5dXU2&JKKIr   r   c                 .    [         R                  X5        g)zE
Remove the given watch descriptor from the inotify file descriptor.
N)r   inotify_rm_watch)r   r   s     r   remover#   2   s    0 	"!r   r   c                    S H  n[        XS5      b  M  [        S5      e   / U R                  l        [        R
                  U R                  l        [        R
                  [        R
                  /U R                  l        [        R
                  U R                  l        [        R
                  [        R                  [        R                  /U R                  l        [        R
                  U R                  l        g)z
Initialize the module, checking if the expected APIs exist and setting the
argtypes and restype for C{inotify_init}, C{inotify_add_watch}, and
C{inotify_rm_watch}.
)r   r   r"   Nzlibc6 2.4 or higher needed)getattrImportErrorr   argtypesctypesc_intrestyper"   c_char_pc_uint32r   )r   functions     r   initializeModuler.   M   s     N44(0:;; N "$D &D&,llFLL%AD"$*LLD!'-||V__foo&VD#%+\\D"r   czCan't find C library.)r   r(   ctypes.utiltypingr   r   twisted.python.filepathr   	Exceptionr   r   r   r    r#   CDLLr.   utilfind_librarynamer&   cdllLoadLibraryr   r	   r   r   <module>r:      s   
    ,9 c C x} C C "s " " "626;; 24 2& {{$
-
..{{t$  r   