inotify_simple.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:inotify_simple 作者: chrisjbillington 项目源码 文件源码
def parse_events(data):
    """Parse data read from an inotify file descriptor into list of
    :attr:`~inotify_simple.Event` namedtuples (wd, mask, cookie, name). This
    function can be used if you have decided to call ``os.read()`` on the
    inotify file descriptor yourself, instead of calling
    :func:`~inotify_simple.INotify.read`.

    Args:
        data (bytes): A bytestring as read from an inotify file descriptor
    Returns:
        list: list of :attr:`~inotify_simple.Event` namedtuples"""
    events = []
    offset = 0
    buffer_size = len(data)
    while offset < buffer_size:
        wd, mask, cookie, namesize = struct.unpack_from(_EVENT_STRUCT_FORMAT, data, offset)
        offset += _EVENT_STRUCT_SIZE
        name = _fsdecode(ctypes.c_buffer(data[offset:offset + namesize], namesize).value)
        offset += namesize
        events.append(Event(wd, mask, cookie, name))
    return events
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号