%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/pyudev/_os/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/pyudev/_os/__pycache__/pipe.cpython-312.pyc

�

9*�bL���dZddlZddlZddlmZddlmZmZmZddl	m
Z
eedd�Zd�Z
d	�Zd
�Ze�Zd�Zd�ZGd
�d�Zy)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>
�N)�partial)�ERROR_CHECKERS�FD_PAIR�
SIGNATURES)�load_ctypes_library�	O_CLOEXECic�N�t�}|j||�|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�fdss   �1/usr/lib/python3/dist-packages/pyudev/_os/pipe.py�
_pipe2_ctypesr-s+���)�C��J�J�s�E���q�6�3�q�6�>��c���tj�}|tjzdk7r!|D]}t|tj��|tzdk7r|D]}t|t��|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�file_descriptors   r�_pipe2_by_piper;sh��
�'�'�)�C��r�}�}���!�"�	?�O����
�
�>�	?��y��A��"�	4�O����3�	4��Jrc���ttd�rtjS	tdtt
�}t|d�rt
t|�StS#t$r	tcYSwxYw)zf
    Find the appropriate implementation for ``pipe2``.

    Return a function implementing ``pipe2``.rr)
�hasattrrrrrrrrr�ImportError)rs r�_get_pipe2_implementationrQsa��
�r�7���x�x���"�6�:�~�F��,3�D�'�,B�G�M�4�(�	
�HV�	
�������s�0A�A�A+�*A+c��tj|tjd�}tj|tj||z�y)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��fd�flagr
s   rrrd�2��
�K�K��E�M�M�1�-�E�	�K�K��E�M�M�5�4�<�0rc��tj|tjd�}tj|tj||z�y)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"s   rrrnr%rc�,�eZdZdZed��Zd�Zd�Zy)�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�Z�ttjtz�\}}|||�S)zLOpen and return a new :class:`Pipe`.

        The pipe uses non-blocking IO.)�_PIPE2rrr)�cls�source�sinks   r�openz	Pipe.open�s(��
�b�m�m�i�7�8�����6�4� � rc�t�tj|dd�|_tj|dd�|_y)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_fds   r�__init__z
Pipe.__init__�s,��
�i�i�	�4��3����I�I�g�t�Q�/��	rc��	|jj�|jj�y#|jj�wxYw)zCloses both sides of the pipe.N)r.�closer/)r5s rr:z
Pipe.close�s4��	��K�K�����I�I�O�O���D�I�I�O�O��s	�7�AN)�__name__�
__module__�__qualname__�__doc__�classmethodr0r8r:�rrr*r*xs%����!��!�0�rr*)r>rr�	functoolsr�pyudev._ctypeslib.libcrrr�pyudev._ctypeslib.utilsr�getattrrrrrr,rrr*r@rr�<module>rEs^��"
� 
�	��G�F�7�
�B��Y�/�	���,
� 
#�	$��1�1� � r

Zerion Mini Shell 1.0