�
Ϫ�f;8 � � � d Z ddlZddlZddlmZ ddlmZ ddlmZm Z dZ
dZdZd Z
d
ZdZdZd
ZdZdZdZdZdZdZdZdZdZdZdZdZe
ez Zeez Zeez Z eez ez ez ez ez ez ez ez Z!e
dfedfedfe
dfedfedfed fed!fed"fed#fed$fed%fed&fed'fed(fed)fed*fed+fed,fed-fgZ"d.� Z# G d/� d0� Z$ G d1� d2e� Z%ejL Z&g d3�Z'y)4a
This module provides support for Twisted to linux inotify API.
In order to use this support, simply do the following (and start a reactor
at some point)::
from twisted.internet import inotify
from twisted.python import filepath
def notify(ignored, filepath, mask):
"""
For historical reasons, an opaque handle is passed as first
parameter. This object should never be used.
@param filepath: FilePath on which the event happened.
@param mask: inotify event as hexadecimal masks
"""
print("event %s on %s" % (
', '.join(inotify.humanReadableMask(mask)), filepath))
notifier = inotify.INotify()
notifier.startReading()
notifier.watch(filepath.FilePath("/some/directory"), callbacks=[notify])
notifier.watch(filepath.FilePath(b"/some/directory2"), callbacks=[notify])
Note that in the above example, a L{FilePath} which is a L{bytes} path name
or L{str} path name may be used. However, no matter what type of
L{FilePath} is passed to this module, internally the L{FilePath} is
converted to L{bytes} according to L{sys.getfilesystemencoding}.
For any L{FilePath} returned by this module, the caller is responsible for
converting from a L{bytes} path name to a L{str} path name.
@since: 10.1
� N)�fdesc)�FileDescriptor)�_inotify�log� � � � � � �@ � � i i i i i @ i � i i i i @l �access�modify�attrib�close_write�
close_nowrite�open�
moved_from�moved_to�create�delete�delete_self� move_self�unmount�queue_overflow�ignored�only_dir�dont_follow�mask_add�is_dir�one_shotc �T � g }t D ] \ }}|| z s�|j |� � |S )zh
Auxiliary function that converts a hexadecimal mask into a series
of human readable flags.
)�_FLAG_TO_HUMAN�append)�mask�s�k�vs �:/usr/lib/python3/dist-packages/twisted/internet/inotify.py�humanReadableMaskr, q s5 � �
�A�� ���1��t�8�
�H�H�Q�K��
�H� c �$ � e Zd ZdZeddfd�Zd� Zy)�_Watcha�
Watch object that represents a Watch point in the filesystem. The
user should let INotify to create these objects
@ivar path: The path over which this watch point is monitoring
@ivar mask: The events monitored by this watchpoint
@ivar autoAdd: Flag that determines whether this watch point
should automatically add created subdirectories
@ivar callbacks: L{list} of callback functions that will be called
when an event occurs on this watch.
FNc �` � |j � | _ || _ || _ |�g }|| _ y �N)�asBytesMode�pathr' |