HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/serial/tools/__pycache__/hexlify_codec.cpython-38.pyc
U

��WW5�	@s�dZddlZddlZzeWneefk
r8eZYnXdZddd�Zddd�Z	Gd	d
�d
ej
�Z
Gdd�dej�ZGd
d�dej�ZGdd�de
ej
�Z
Gdd�de
ej�Zdd�ZdS)aLPython 'hex' Codec - 2-digit hex with spaces content transfer encoding.

Encode and decode may be a bit missleading at first sight...

The textual representation is a hex dump: e.g. "40 41"
The "encoded" data of this is the binary form, e.g. b"@A"

Therefore decoding is binary to text and thus converting binary data to hex dump.

�NZ0123456789ABCDEF�strictcCs t�dd�|��D��t|�fS)�'40 41 42' -> b'@ab'cSsg|]}t|d��qS����int��.0�h�r�</usr/lib/python3/dist-packages/serial/tools/hexlify_codec.py�
<listcomp>&szhex_encode.<locals>.<listcomp>)�serial�to_bytes�split�len��data�errorsrrr�
hex_encode$srcCs&td�dd�t�|�D���t|�fS)�b'@ab' -> '40 41 42'�css|]}d�t|��VqdS�z{:02X} N��format�ord�r	�brrr�	<genexpr>+szhex_decode.<locals>.<genexpr>)�unicode�joinr�	iterbytesrrrrr�
hex_decode)sr"c@s eZdZddd�Zddd�ZdS)	�CodecrcCst�dd�|��D��S)rcSsg|]}t|d��qSrrrrrrr
1sz Codec.encode.<locals>.<listcomp>)rrr��selfrrrrr�encode/szCodec.encodecCstd�dd�t�|�D���S)rrcss|]}d�t|��VqdSrrrrrrr5szCodec.decode.<locals>.<genexpr>�rr rr!r$rrr�decode3szCodec.decodeN)r)r)�__name__�
__module__�__qualname__r&r(rrrrr#.s
r#c@s<eZdZdZddd�Zdd�Zdd�Zd	d
�Zddd
�ZdS)�IncrementalEncoderzIncremental hex encoderrcCs||_d|_dS�Nr)r�state)r%rrrr�__init__;szIncrementalEncoder.__init__cCs
d|_dSr-�r.�r%rrr�reset?szIncrementalEncoder.resetcCs|jS�Nr0r1rrr�getstateBszIncrementalEncoder.getstatecCs
||_dSr3r0)r%r.rrr�setstateEszIncrementalEncoder.setstateFcCs�|j}g}|��D]|}|tkrRt�|�}|rD|�||d@�d}q�d|d>}q|dkrv|rp|jdkrptd��d}q|jdkrtd�|���q||_t�	|�S)	z�        Incremental encode, keep track of digits and emit a byte when a pair
        of hex digits is found. The space is optional unless the error
        handling is defined to be 'strict'.
        ��r��� rzodd number of hex digitsznon-hex digit found: {!r})
r.�upper�	HEXDIGITS�index�appendr�UnicodeErrorrrr)r%r�finalr.Zencoded�c�zrrrr&Hs"

zIncrementalEncoder.encodeN)r)F)	r)r*r+�__doc__r/r2r4r5r&rrrrr,8s
r,c@seZdZdZddd�ZdS)�IncrementalDecoderzIncremental decoderFcCstd�dd�t�|�D���S)Nrcss|]}d�t|��VqdSrrrrrrrfsz,IncrementalDecoder.decode.<locals>.<genexpr>r')r%rr?rrrr(eszIncrementalDecoder.decodeN)F)r)r*r+rBr(rrrrrCcsrCc@seZdZdZdS)�StreamWriterz-Combination of hexlify codec and StreamWriterN�r)r*r+rBrrrrrDisrDc@seZdZdZdS)�StreamReaderz-Combination of hexlify codec and StreamReaderNrErrrrrFmsrFc	Cstjdttttttd�S)zencodings module APIZhexlify)�namer&r(�incrementalencoder�incrementaldecoder�streamwriter�streamreader)�codecs�	CodecInforr"r,rCrDrFrrrr�getregentryqs�rN)r)r)rBrLrr�	NameError�AttributeError�strr;rr"r#r,rCrDrFrNrrrr�<module>	s



+