Current Dir: /snap/core22/2955/usr/lib/python3/dist-packages/pyudev/_os/__pycache__/

[FILE] pipe.cpython-310.pyc [ edit | delete | rename ]
[FILE] poll.cpython-310.pyc [ edit | delete | rename ]
[FILE] __init__.cpython-310.pyc [ edit | delete | rename ]

Viewing: /snap/core22/2955/usr/lib/python3/dist-packages/pyudev/_os/__pycache__/pipe.cpython-310.pyc

o

8g+^��@s�dZddlmZddlmZddlmZddlmZddlZddlZddlm	Z	ddl
mZdd	l
mZdd
l
m
Z
ddlmZeedd
�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�1/usr/lib/python3/dist-packages/pyudev/_os/pipe.py�
_pipe2_ctypes2s	rcCsPt��}|tj@dkr|D]}t|tj�q
|t@dkr&|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@srcCsPttd�rtjSztdtt�}t|d�rtt|�WStWSt	y'tYSw)z]Find the appropriate implementation for ``pipe2``.

Return a function implementing ``pipe2``.r
r)
�hasattrrr
r
r	rrrr�ImportError)rrrr�_get_pipe2_implementationVs
���rcC�(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)�fcntl�F_GETFD�F_SETFD�r�flagrrrrrh�rcCr)z~Set a status flag on a file descriptor.

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

    rN)r�F_GETFL�F_SETFLr"rrrrrr$rc@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�s
z	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+)�self�	source_fd�sink_fdrrr�__init__�sz
Pipe.__init__cCs(z
|j��W|j��dS|j��w)zCloses both sides of the pipe.N)r*�closer+)r0rrrr4�sz
Pipe.closeN)�__name__�
__module__�__qualname__�__doc__�classmethodr,r3r4rrrrr'|s

r')r8�
__future__rrrrrr�	functoolsr�pyudev._ctypeslib.libcrrr	�pyudev._ctypeslib.utilsr
�getattrrrrrr(rr�objectr'rrrr�<module>s(


Upload File: