Your IP : 3.145.32.238


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/xdrlib.cpython-310.opt-1.pyc

o

6��f�@stdZddlZddlmZddlmZgd�ZGdd�de�ZGdd	�d	e�Z	d
d�Z
Gdd
�d
�ZGdd�d�ZdS)zRImplements (a subset of) Sun XDR -- eXternal Data Representation.

See: RFC 1014

�N)�BytesIO��wraps)�Error�Packer�Unpacker�ConversionErrorc@s(eZdZdZdd�Zdd�Zdd�ZdS)	rz�Exception class for this module. Use:

    except xdrlib.Error as var:
        # var has the Error instance for the exception

    Public ivars:
        msg -- contains the message

    cC�
||_dS�N)�msg)�selfr�r
�-/opt/alt/python310/lib64/python3.10/xdrlib.py�__init__�
zError.__init__cC�
t|j�Sr
)�reprr�rr
r
r�__repr__rzError.__repr__cCrr
)�strrrr
r
r�__str__rz
Error.__str__N)�__name__�
__module__�__qualname__�__doc__rrrr
r
r
rrs
	rc@seZdZdS)rN)rrrr
r
r
rr srcst���fdd��}|S)z5 Wrap any raised struct.errors in a ConversionError. c
s8z�||�WStjy}zt|jd�d�d}~ww�Nr)�struct�errorr�args)r�value�e��functionr
r�result&s��z&raise_conversion_error.<locals>.resultr)r"r#r
r!r�raise_conversion_error#sr$c@s�eZdZdZdd�Zdd�Zdd�ZeZedd	��Z	ed
d��Z
e
Zdd
�Zdd�Z
e
Zedd��Zedd��Zdd�ZeZdd�ZeZeZdd�Zdd�Zdd�ZdS)rz0Pack various data representations into a buffer.cCs|��dSr
��resetrr
r
rr2�zPacker.__init__cCst�|_dSr
)r�_Packer__bufrr
r
rr&5r'zPacker.resetcCs
|j��Sr
)r(�getvaluerr
r
r�
get_buffer8rzPacker.get_buffercC�|j�t�d|��dS)N�>L�r(�writerZpack�r�xr
r
r�	pack_uint=�zPacker.pack_uintcCr+)N�>lr-r/r
r
r�pack_intAr2zPacker.pack_intcCs$|r
|j�d�dS|j�d�dS)Nss)r(r.r/r
r
r�	pack_boolGszPacker.pack_boolc
Cs�z|�|d?d@�Wnttjfy"}zt|jd�d�d}~wwz
|�|d@�WdSttjfyD}zt|jd�d�d}~ww)N� l��r)r1�	TypeErrorrrrr)rr0r r
r
r�pack_uhyperKs����zPacker.pack_uhypercCr+)N�>fr-r/r
r
r�
pack_floatWr2zPacker.pack_floatcCr+)N�>dr-r/r
r
r�pack_double[r2zPacker.pack_doublecCsP|dkrtd��|d|�}|ddd}||t|�d}|j�|�dS)Nr� fstring size must be nonnegative���)�
ValueError�lenr(r.)r�n�s�datar
r
r�pack_fstring_szPacker.pack_fstringcCs"t|�}|�|�|�||�dSr
)rBr1rF)rrDrCr
r
r�pack_stringis
zPacker.pack_stringcCs*|D]}|�d�||�q|�d�dS)N�r)r1)r�list�	pack_item�itemr
r
r�	pack_listqs

zPacker.pack_listcCs*t|�|kr
td��|D]}||�qdS)Nzwrong array size)rBrA)rrCrIrJrKr
r
r�pack_farrayws

�zPacker.pack_farraycCs$t|�}|�|�|�|||�dSr
)rBr1rM)rrIrJrCr
r
r�
pack_array}s
zPacker.pack_arrayN)rrrrrr&r*Zget_bufr$r1r4Z	pack_enumr5r8Z
pack_hyperr:r<rFZpack_fopaquerGZpack_opaqueZ
pack_bytesrLrMrNr
r
r
rr/s4




rc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZeZdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZeZdd�ZeZeZd d!�Zd"d#�Zd$d%�Zd&S)'rz;Unpacks various data representations from the given buffer.cCs|�|�dSr
r%�rrEr
r
rr�szUnpacker.__init__cCs||_d|_dSr)�_Unpacker__buf�_Unpacker__posrOr
r
rr&�s
zUnpacker.resetcC�|jSr
�rQrr
r
r�get_position��zUnpacker.get_positioncCr	r
rS)rZpositionr
r
r�set_position�rzUnpacker.set_positioncCrRr
)rPrr
r
rr*�rUzUnpacker.get_buffercCs|jt|j�krtd��dS)Nzunextracted data remains)rQrBrPrrr
r
r�done�s�z
Unpacker.donecC�B|j}|d|_}|j||�}t|�dkrt�t�d|�dS)Nr?r,r�rQrPrB�EOFErrorrZunpack�r�i�jrEr
r
r�unpack_uint��zUnpacker.unpack_uintcCrX)Nr?r3rrYr[r
r
r�
unpack_int�r_zUnpacker.unpack_intcCst|���Sr
)�boolr`rr
r
r�unpack_bool�r'zUnpacker.unpack_boolcCs |��}|��}t|�d>|BS)Nr6)r^�int)r�hi�lor
r
r�
unpack_uhyper�szUnpacker.unpack_uhypercCs|��}|dkr|d}|S)Nll)rfr/r
r
r�unpack_hyper�szUnpacker.unpack_hypercCrX)Nr?r9rrYr[r
r
r�unpack_float�r_zUnpacker.unpack_floatcCrX)N�r;rrYr[r
r
r�
unpack_double�r_zUnpacker.unpack_doublecCsT|dkrtd��|j}||ddd}|t|j�krt�||_|j|||�S)Nrr=r>r?)rArQrBrPrZ)rrCr\r]r
r
r�unpack_fstring�szUnpacker.unpack_fstringcCs|��}|�|�Sr
)r^rk)rrCr
r
r�
unpack_string�s
zUnpacker.unpack_stringcCsBg}	|��}|dkr
|S|dkrtd|f��|�}|�|�q)NrHrz0 or 1 expected, got %r)r^r�append)r�unpack_itemrIr0rKr
r
r�unpack_list�s�
�zUnpacker.unpack_listcCs"g}t|�D]}|�|��q|Sr
)�rangerm)rrCrnrIr\r
r
r�
unpack_farray�szUnpacker.unpack_farraycCs|��}|�||�Sr
)r^rq)rrnrCr
r
r�unpack_array�szUnpacker.unpack_arrayN)rrrrrr&rTrVr*rWr^r`Zunpack_enumrbrfrgrhrjrkZunpack_fopaquerlZ
unpack_opaqueZunpack_bytesrorqrrr
r
r
rr�s0
r)
rr�ior�	functoolsr�__all__�	Exceptionrrr$rrr
r
r
r�<module>sU

?>