Edit File: pipe.cpython-36.pyc
3 u1�W�������������������@���s����d�Z�ddlmZ�ddlmZ�ddlmZ�ddlmZ�ddlZddlZddlm Z �ddl mZ�dd l mZ�dd l m Z �ddlmZ�eedd �Zdd��Zdd��Zdd��Ze��Zdd��Zdd��ZG�dd��de�ZdS�)a#�� pyudev._os.pipe =============== Fallback implementations for pipe. 1. pipe2 from python os module 2. pipe2 from libc 3. pipe from python os module The Pipe class wraps the chosen implementation. .. moduleauthor:: Sebastian Wiesner <lunaryorn@gmail.com> �����)�absolute_import)�division)�print_function)�unicode_literalsN)�partial)�fd_pair)�ERROR_CHECKERS)� SIGNATURES)�load_ctypes_library� O_CLOEXECi���c�������������C���s"���t���}|�j||��|d�|d�fS�)z�A ``pipe2`` implementation using ``pipe2`` from ctypes. ``libc`` is a :class:`ctypes.CDLL` object for libc. ``flags`` is an integer providing the flags to ``pipe2``. Return a pair of file descriptors ``(r, w)``. r�������)r����pipe2)�libc�flags�fds��r����/usr/lib/python3.6/pipe.py� _pipe2_ctypes4���s���� r���c�������������C���sX���t�j��}|�t�j@�dkr0x|D�]}t|t�j��qW�|�t@�dkrTx|D�]}t|t��qBW�|S�)z�A ``pipe2`` implementation using :func:`os.pipe`. ``flags`` is an integer providing the flags to ``pipe2``. .. warning:: This implementation is not atomic! Return a pair of file descriptors ``(r, w)``. r���)�os�pipe� O_NONBLOCK�set_fd_status_flagr����set_fd_flag)r���r����fdr���r���r����_pipe2_by_pipeB���s���� r���c��������������C���sN���t�td�rtjS�y$tdtt�}�t�|�d�r2tt|��S�tS��t k rH���tS�X�dS�)z]Find the appropriate implementation for ``pipe2``. Return a function implementing ``pipe2``.r ���r���N) �hasattrr���r ���r ���r ���r���r���r���r����ImportError)r���r���r���r����_get_pipe2_implementationX���s���� r���c�������������C���s(���t�j�|�t�jd�}t�j�|�t�j||B���dS�)zwSet a flag on a file descriptor. ``fd`` is the file descriptor or file object, ``flag`` the flag as integer. r���N)�fcntlZF_GETFDZF_SETFD)r����flagr���r���r���r���r���k���s����r���c�������������C���s(���t�j�|�t�jd�}t�j�|�t�j||B���dS�)z~Set a status flag on a file descriptor. ``fd`` is the file descriptor or file object, ``flag`` the flag as integer. r���N)r���ZF_GETFLZF_SETFL)r���r���r���r���r���r���r���u���s����r���c���������������@���s,���e�Zd�ZdZedd���Zdd��Zdd��ZdS�) �Pipez�A unix pipe. A pipe object provides two file objects: :attr:`source` is a readable file object, and :attr:`sink` a writeable. Bytes written to :attr:`sink` appear at :attr:`source`. Open a pipe with :meth:`open()`. c�������������C���s���t�tjtB��\}}|�||�S�)zLOpen and return a new :class:`Pipe`. The pipe uses non-blocking IO.)�_PIPE2r���r���r���)�cls�source�sinkr���r���r����open����s����z Pipe.openc�������������C���s$���t�j|dd�|�_t�j|dd�|�_dS�)z�Create a new pipe object from the given file descriptors. ``source_fd`` is a file descriptor for the readable side of the pipe, ``sink_fd`` is a file descriptor for the writeable side.�rbr����wbN)r����fdopenr#���r$���)�selfZ source_fdZsink_fdr���r���r����__init__����s����z Pipe.__init__c���������� ���C���s ���z|�j�j���W�d|�jj���X�dS�)zCloses both sides of the pipe.N)r#����closer$���)r)���r���r���r���r+�������s����z Pipe.closeN)�__name__� __module__�__qualname__�__doc__�classmethodr%���r*���r+���r���r���r���r���r ������s��� r ���)r/���Z __future__r���r���r���r���r���r���� functoolsr���Zpyudev._ctypeslib.libcr���r���r ���Zpyudev._ctypeslib.utilsr ����getattrr���r���r���r���r!���r���r����objectr ���r���r���r���r����<module> ���s&���