ó
[³XMc           @   sŸ   d  Z  d d l Z d d l Z d e f d „  ƒ  YZ d „  Z d „  Z d „  Z d „  Z e j	 j
 d	 ƒ Z e s e d
 ƒ ‚ n  e j j e ƒ Z e e ƒ d S(   sŒ   
Very low-level ctypes-based interface to Linux inotify(7).

ctypes and a version of libc which supports inotify system calls are
required.
iÿÿÿÿNt   INotifyErrorc           B   s   e  Z d  Z RS(   sR   
    Unify all the possible exceptions that can be raised by the INotify API.
    (   t   __name__t
   __module__t   __doc__(    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/python/_inotify.pyR       s   c          C   s+   t  j ƒ  }  |  d k  r' t d ƒ ‚ n  |  S(   sO   
    Create an inotify instance and return the associated file descriptor.
    i    s   INotify initialization error.(   t   libct   inotify_initR    (   t   fd(    (    s;   /usr/lib/python2.7/dist-packages/twisted/python/_inotify.pyt   init   s    c         C   s>   t  j |  | | ƒ } | d k  r: t d | | f ƒ ‚ n  | S(   sm   
    Add a watch for the given path to the inotify file descriptor, and return
    the watch descriptor.
    i    s"   Failed to add watch on '%r' - (%r)(   R   t   inotify_add_watchR    (   R   t   patht   maskt   wd(    (    s;   /usr/lib/python2.7/dist-packages/twisted/python/_inotify.pyt   add#   s    c         C   s   t  j |  | ƒ d S(   sM   
    Remove the given watch descriptor from the inotify file descriptor.
    N(   R   t   inotify_rm_watch(   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/python/_inotify.pyt   remove/   s    c         C   sZ   x5 d D]- } t  |  | d ƒ d k r t d ƒ ‚ q q Wt j t j t j g |  j _ d S(   sz   
    Intialize the module, checking if the expected APIs exist and setting the
    argtypes for C{inotify_add_watch}.
    R   R   R   s   libc6 2.4 or higher neededN(   s   inotify_add_watchs   inotify_inits   inotify_rm_watch(   t   getattrt   Nonet   ImportErrort   ctypest   c_intt   c_char_pR   t   argtypes(   R   t   function(    (    s;   /usr/lib/python2.7/dist-packages/twisted/python/_inotify.pyt   initializeModuleK   s    t   cs   Can't find C library.(   R   R   t   ctypes.utilt	   ExceptionR    R   R   R   R   t   utilt   find_libraryt   nameR   t   cdllt   LoadLibraryR   (    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/python/_inotify.pyt   <module>
   s   				