JFIF$        dd7 

Viewing File: /usr/lib/python3.9/site-packages/pyudev/_os/__pycache__/pipe.cpython-39.pyc

a

8g+^��@s�dZddlmZddlmZddlmZddlmZddlZddlZddlm	Z	ddl
mZdd	l
mZdd
l
m
Z
ddlmZeedd
�Zdd�Zdd�Zdd�Ze�Zdd�Zdd�ZGdd�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)�ERROR_CHECKERS)�FD_PAIR)�
SIGNATURES)�load_ctypes_library�	O_CLOEXECicCs"t�}|�||�|d|dfS)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�3/usr/lib/python3.9/site-packages/pyudev/_os/pipe.py�
_pipe2_ctypes2s	rcCsPt��}|tj@dkr,|D]}t|tj�q|t@dkrL|D]}t|t�q<|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)rr�fdrrr�_pipe2_by_pipe@srcCsRttd�rtjSz&tdtt�}t|d�r2tt|�ntWSt	yLtYS0dS)z]Find the appropriate implementation for ``pipe2``.

Return a function implementing ``pipe2``.r
rN)
�hasattrrr
r
r	rrrr�ImportError)rrrr�_get_pipe2_implementationVs
��rcCs(t�|tjd�}t�|tj||B�dS)zwSet a flag on a file descriptor.

    ``fd`` is the file descriptor or file object, ``flag`` the flag as integer.

    rN)�fcntlZF_GETFDZF_SETFD�r�flagrrrrrhsrcCs(t�|tjd�}t�|tj||B�dS)z~Set a status flag on a file descriptor.

    ``fd`` is the file descriptor or file object, ``flag`` the flag as integer.

    rN)rZF_GETFLZF_SETFLrrrrrrsrc@s,eZdZdZedd��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()`.

    cCsttjtB�\}}|||�S)zLOpen and return a new :class:`Pipe`.

        The pipe uses non-blocking IO.)�_PIPE2rrr)�cls�source�sinkrrr�open�sz	Pipe.opencCs$t�|dd�|_t�|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_fdrrr�__init__�sz
Pipe.__init__cCs*z|j��W|j��n|j��0dS)zCloses both sides of the pipe.N)r$�closer%)r*rrrr,�sz
Pipe.closeN)�__name__�
__module__�__qualname__�__doc__�classmethodr&r+r,rrrrr!|s


r!)r0Z
__future__rrrrrr�	functoolsrZpyudev._ctypeslib.libcrrr	Zpyudev._ctypeslib.utilsr
�getattrrrrrr"rr�objectr!rrrr�<module>s&

Back to Directory  nL+D550H?Mx ,D"v]qv;6*Zqn)ZP0!1 A "#a$2Qr D8 a Ri[f\mIykIw0cuFcRı?lO7к_f˓[C$殷WF<_W ԣsKcëIzyQy/_LKℂ;C",pFA:/]=H  ~,ls/9ć:[=/#f;)x{ٛEQ )~ =𘙲r*2~ a _V=' kumFD}KYYC)({ *g&f`툪ry`=^cJ.I](*`wq1dđ#̩͑0;H]u搂@:~וKL Nsh}OIR*8:2 !lDJVo(3=M(zȰ+i*NAr6KnSl)!JJӁ* %݉?|D}d5:eP0R;{$X'xF@.ÊB {,WJuQɲRI;9QE琯62fT.DUJ;*cP A\ILNj!J۱+O\͔]ޒS߼Jȧc%ANolՎprULZԛerE2=XD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