a �DOg�@spddlZddlmZddlmZgd�ZGdd�de�ZGdd�de�Zd d �Z Gd d �d �Z Gd d�d�Z dS)�N)�BytesIO��wraps)�Error�Packer�Unpacker�ConversionErrorc@s$eZdZdd�Zdd�Zdd�ZdS)rcCs ||_dS�N)�msg)�selfr �r �/usr/lib64/python3.9/xdrlib.py�__init__szError.__init__cCs t|j�Sr )�reprr �r r r r �__repr__szError.__repr__cCs t|j�Sr )�strr rr r r �__str__sz Error.__str__N)�__name__� __module__� __qualname__rrrr r r r rs rc@s eZdZdS)rN)rrrr r r r r srcst���fdd��}|S)Nc sHz �||�WStjyB}zt|jd�d�WYd}~n d}~00dS�Nr)�struct�errorr�args)r �value�e��functionr r �result&s z&raise_conversion_error..resultr)rrr rr �raise_conversion_error#sr c@s�eZdZdd�Zdd�Zdd�ZeZedd��Zed d ��Z e Z d d �Z d d�Z e Z edd��Zedd��Zdd�ZeZdd�ZeZeZdd�Zdd�Zdd�ZdS)rcCs |��dSr ��resetrr r r r2szPacker.__init__cCs t�|_dSr )r� _Packer__bufrr r r r"5sz Packer.resetcCs |j��Sr )r#�getvaluerr r r � get_buffer8szPacker.get_buffercCs|j�t�d|��dS)N�>L�r#�writer�pack�r �xr r r � pack_uint=szPacker.pack_uintcCs|j�t�d|��dS)N�>lr'r*r r r �pack_intAszPacker.pack_intcCs"|r|j�d�n |j�d�dS)Nss)r#r(r*r r r � pack_boolGszPacker.pack_boolc Cs�z|�|d?d@�Wn:ttjfyP}zt|jd�d�WYd}~n d}~00z|�|d@�Wn:ttjfy�}zt|jd�d�WYd}~n d}~00dS)N� l��r)r,� TypeErrorrrrr)r r+rr r r � pack_uhyperKs&zPacker.pack_uhypercCs|j�t�d|��dS)N�>fr'r*r r r � pack_floatWszPacker.pack_floatcCs|j�t�d|��dS)N�>dr'r*r r r � pack_double[szPacker.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 )r<r,r@)r r>r=r r r � pack_stringis zPacker.pack_stringcCs*|D]}|�d�||�q|�d�dS)N�r)r,)r �list� pack_item�itemr r r � pack_listqs  zPacker.pack_listcCs*t|�|krtd��|D] }||�qdS)Nzwrong array size)r<r;)r r=rCrDrEr r r � pack_farrayws zPacker.pack_farraycCs$t|�}|�|�|�|||�dSr )r<r,rG)r rCrDr=r r r � pack_array}s zPacker.pack_arrayN)rrrrr"r%Zget_bufr r,r.Z pack_enumr/r2Z pack_hyperr4r6r@Z pack_fopaquerAZ pack_opaqueZ pack_bytesrFrGrHr r r r r/s0     rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd d �Zd d �Zd d�Z dd�Z e Z dd�Z dd�Z dd�Zdd�Zdd�Zdd�ZeZdd�ZeZeZdd �Zd!d"�Zd#d$�Zd%S)&rcCs|�|�dSr r!�r r?r r r r�szUnpacker.__init__cCs||_d|_dSr)�_Unpacker__buf�_Unpacker__posrIr r r r"�szUnpacker.resetcCs|jSr �rKrr r r � get_position�szUnpacker.get_positioncCs ||_dSr rL)r Zpositionr r r � set_position�szUnpacker.set_positioncCs|jSr )rJrr r r r%�szUnpacker.get_buffercCs|jt|j�krtd��dS)Nzunextracted data remains)rKr<rJrrr r r �done�sz Unpacker.donecCsB|j}|d|_}|j||�}t|�dkr2t�t�d|�dS)Nr9r&r�rKrJr<�EOFErrorr�unpack�r �i�jr?r r r � unpack_uint�s  zUnpacker.unpack_uintcCsB|j}|d|_}|j||�}t|�dkr2t�t�d|�dS)Nr9r-rrPrSr r r � unpack_int�s  zUnpacker.unpack_intcCs t|���Sr )�boolrWrr r r � unpack_bool�szUnpacker.unpack_boolcCs |��}|��}t|�d>|BS)Nr0)rV�int)r �hi�lor r r � unpack_uhyper�szUnpacker.unpack_uhypercCs|��}|dkr|d}|S)Nll)r]r*r r r � unpack_hyper�szUnpacker.unpack_hypercCsB|j}|d|_}|j||�}t|�dkr2t�t�d|�dS)Nr9r3rrPrSr r r � unpack_float�s  zUnpacker.unpack_floatcCsB|j}|d|_}|j||�}t|�dkr2t�t�d|�dS)N�r5rrPrSr r r � unpack_double�s  zUnpacker.unpack_doublecCsT|dkrtd��|j}||ddd}|t|j�kr|dkr,td|f��|�}|�|�q|S)NrrBz0 or 1 expected, got %r)rVr�append)r � unpack_itemrCr+rEr r r � unpack_list�s  zUnpacker.unpack_listcCs"g}t|�D]}|�|��q |Sr )�rangerd)r r=rerCrTr r r � unpack_farray�s zUnpacker.unpack_farraycCs|��}|�||�Sr )rVrh)r rer=r r r � unpack_array�szUnpacker.unpack_arrayN)rrrrr"rMrNr%rOrVrWZ unpack_enumrYr]r^r_rarbZunpack_fopaquercZ unpack_opaqueZ unpack_bytesrfrhrir r r r r�s,  r) r�ior� functoolsr�__all__� Exceptionrrr rrr r r r �s   U