/usr/lib/python3/dist-packages/jeepney/__pycache__
Edit: /usr/lib/python3/dist-packages/jeepney/__pycache__/fds.cpython-310.pyc (5619B)
o
` @ sR d dl Z d dlZd dlZd dlmZ G dd deZG dd dZdadd Z dS ) N)warnc @ s e Zd ZdZdS ) NoFDErrorzQRaised by :class:`FileDescriptor` methods if it was already closed/converted
N)__name__
__module____qualname____doc__ r r -/usr/lib/python3/dist-packages/jeepney/fds.pyr s r c @ s e Zd ZdZdZdZdZdd Zdd Zd d
Z dd Z
d
d Zdd Zdd Z
dd Zdd ZdddZdd Zedd gfddZdS ) 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.
_fdc C s
|| _ d S Nr selffdr r r __init__ s
zFileDescriptor.__init__c C s4 | j }| j | jkrd}n| j | jkrd}d| dS )Nclosed convertedz
)r _CLOSED
_CONVERTEDr detailr r r __repr__ s zFileDescriptor.__repr__c C sB | j | jkrdS | j | jkrtd| j| j | _ }t| dS )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 oscloser r r r r $ s zFileDescriptor.closec C s | S r r r r r r __enter__5 s zFileDescriptor.__enter__c C s | d S r )r )r exc_typeexc_valexc_tbr r r __exit__8 s zFileDescriptor.__exit__c C s4 | j dkrtd| j dtd| d | d S d S )Nr zFileDescriptor (z") was neither closed nor converted )
stacklevelsource)r r ResourceWarningr r r r r __del__; s
zFileDescriptor.__del__c C s0 | j dk r| j | jkr
dnd}td| d S )Nr r r z"FileDescriptor object was already )r r r r r r r _checkC s
zFileDescriptor._checkc C s | | jS )zGet the integer file descriptor
This does not change the state of the :class:`FileDescriptor` object,
unlike the ``to_*`` methods.
)r( r r r r r filenoH s zFileDescriptor.filenoc C s | | j| j| _}|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.
)r( r r r r r r to_raw_fdQ s
zFileDescriptor.to_raw_fdNc C s* | t| j|||||d}| j| _|S )aK Convert to a Python file object::
with fd.to_file('w') as f:
f.write('xyz')
The arguments are the same as for the builtin :func:`open` function.
The :class:`FileDescriptor` can't be used after calling this. Closing
the file object will also close the file descriptor.
) bufferingencodingerrorsnewline)r( openr r )r moder+ r, r- r. fr r r to_file_ s zFileDescriptor.to_filec C s, ddl m } | || jd}| j| _|S )aC Convert to a socket object
This returns a standard library :func:`socket.socket` object::
with fd.to_socket() as sock:
b = sock.sendall(b'xyz')
The wrapper object can't be used after calling this. Closing the socket
object will also close the file descriptor.
r )socket)r) )r3 r( r r )r r3 sr r r to_socketr s
zFileDescriptor.to_socketreturnc sd t d}|D ]!\}}}|tjkr(|tjkr(||dt|t||j q fdd|D S )zMake a list of FileDescriptor from received file descriptors
ancdata is a list of ancillary data tuples as returned by socket.recvmsg()
iNc s g | ]} |qS r r ).0r7 clsr r