%PDF- %PDF-
| Direktori : /lib/python3/dist-packages/jeepney/__pycache__/ |
| Current File : //lib/python3/dist-packages/jeepney/__pycache__/fds.cpython-312.pyc |
�
+�c� � �\ � d dl Z d dlZd dlZd dlmZ G d� de� Z G d� d� Zdad� Z y)� N)�warnc � � e Zd ZdZy)� NoFDErrorzQRaised by :class:`FileDescriptor` methods if it was already closed/converted
N)�__name__�
__module__�__qualname__�__doc__� � �-/usr/lib/python3/dist-packages/jeepney/fds.pyr r s
� ��r r c �x � e Zd ZdZdZdZdZd� Zd� Zd� Z d� Z
d � Zd
� Zd� Z
d� Zd
� Zdd�Zd� Zedd gfd�� Zy)�FileDescriptora+ A file descriptor received in a D-Bus message
This wrapper helps ensure that the file descriptor is closed exactly once.
If you don't explicitly convert or close the FileDescriptor object, it will
close its file descriptor when it goes out of scope, and emit a
ResourceWarning.
��_fd������c � � || _ y �Nr ��self�fds r �__init__zFileDescriptor.__init__ s � ���r c � � | j }| j | j k( rd}n| j | j k( rd}d|� d�S )N�closed� convertedz<FileDescriptor (z)>)r �_CLOSED�
_CONVERTED�r �details r �__repr__zFileDescriptor.__repr__ sD � ������8�8�t�|�|�#��F�
�X�X����
(� �F�"�6�(�"�-�-r c �� � | j | j k( ry| j | j k( rt d� �| j | j c| _ }t j
|� y)a Close the file descriptor
This can safely be called multiple times, but will raise RuntimeError
if called after converting it with one of the ``to_*`` methods.
This object can also be used in a ``with`` block, to close it on
leaving the block.
z.Can't close FileDescriptor after converting itN)r r r r �os�closer s r r# zFileDescriptor.close$ sS � � �8�8�t�|�|�#��
�X�X����
(��L�M�M��<�<����L�D�H�b��H�H�R�Lr c � � | S r r
�r s r � __enter__zFileDescriptor.__enter__5 s � ��r c �$ � | j � y r )r# )r �exc_type�exc_val�exc_tbs r �__exit__zFileDescriptor.__exit__8 s � ��
�
�r c � � | j dk\ r2t d| j � d�t d| �� | j � y y )Nr zFileDescriptor (z") was neither closed nor converted� )�
stacklevel�source)r r �ResourceWarningr# r% s r �__del__zFileDescriptor.__del__; s= � ��8�8�q�=��"�4�8�8�*�,N�O��A�d�
�
�J�J�L� r c �x � | j dk r+| j | j k( rdnd}t d|� �� �y )Nr r r z"FileDescriptor object was already )r r r r s r �_checkzFileDescriptor._checkC s; � ��8�8�a�<�!%���T�\�\�!9�X�{�F��@���I�J�J� r c �: � | j � | j S )z�Get the integer file descriptor
This does not change the state of the :class:`FileDescriptor` object,
unlike the ``to_*`` methods.
)r3 r r% s r �filenozFileDescriptor.filenoH s � �
���
��x�x�r c �b � | j � | j | j c| _ }|S )a, Convert to the low-level integer file descriptor::
raw_fd = fd.to_raw_fd()
os.write(raw_fd, b'xyz')
os.close(raw_fd)
The :class:`FileDescriptor` can't be used after calling this. The caller
is responsible for closing the file descriptor.
)r3 r r r s r � to_raw_fdzFileDescriptor.to_raw_fdQ s'