Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.6/site-packages/serial/tools/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.6/site-packages/serial/tools/__pycache__/hexlify_codec.cpython-36.pyc

3

 ��c]�
@s�dZddlmZddlZddlZyeWneefk
rDeZYnXdZ	ddd�Z
ddd	�ZGd
d�dej�ZGdd
�d
ej
�Z
Gdd�dej�ZGdd�deej�ZGdd�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.

�)�absolute_importNZ0123456789ABCDEF�strictcCs tjdd�|j�D��t|�fS)z'40 41 42' -> b'@ab'cSsg|]}t|d��qS)�)�int)�.0�h�r�>/tmp/pip-build-_uu8ur7s/pyserial/serial/tools/hexlify_codec.py�
<listcomp>(szhex_encode.<locals>.<listcomp>)�serial�to_bytes�split�len)�data�errorsrrr	�
hex_encode&srcCs&tdjdd�tj|�D���t|�fS)zb'@ab' -> '40 41 42'�css|]}djt|��VqdS)z{:02X} N)�format�ord)r�brrr	�	<genexpr>-szhex_decode.<locals>.<genexpr>)�unicode�joinr�	iterbytesr)rrrrr	�
hex_decode+src@s eZdZddd�Zddd�ZdS)	�CodecrcCstjdd�|j�D��S)z'40 41 42' -> b'@ab'cSsg|]}t|d��qS)r)r)rrrrr	r
3sz Codec.encode.<locals>.<listcomp>)rrr
)�selfrrrrr	�encode1szCodec.encodecCstdjdd�tj|�D���S)zb'@ab' -> '40 41 42'rcss|]}djt|��VqdS)z{:02X} N)rr)rrrrr	r7szCodec.decode.<locals>.<genexpr>)rrrr)rrrrrr	�decode5szCodec.decodeN)r)r)�__name__�
__module__�__qualname__rrrrrr	r0s
rc@s<eZdZdZddd�Zdd�Zdd�Zd	d
�Zddd
�ZdS)�IncrementalEncoderzIncremental hex encoderrcCs||_d|_dS)Nr)r�state)rrrrr	�__init__=szIncrementalEncoder.__init__cCs
d|_dS)Nr)r#)rrrr	�resetAszIncrementalEncoder.resetcCs|jS)N)r#)rrrr	�getstateDszIncrementalEncoder.getstatecCs
||_dS)N)r#)rr#rrr	�setstateGszIncrementalEncoder.setstateFcCs�|j}g}x�|j�D]|}|tkrTtj|�}|rF|j||d@�d}q�d|d>}q|dkrx|rr|jdkrrtd��d}q|jdkrtdj|���qW||_tj	|�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)rr�finalr#�encoded�c�zrrr	rJs"

zIncrementalEncoder.encodeN)r)F)	rr r!�__doc__r$r%r&r'rrrrr	r":s
r"c@seZdZdZddd�ZdS)�IncrementalDecoderzIncremental decoderFcCstdjdd�tj|�D���S)Nrcss|]}djt|��VqdS)z{:02X} N)rr)rrrrr	rhsz,IncrementalDecoder.decode.<locals>.<genexpr>)rrrr)rrr1rrr	rgszIncrementalDecoder.decodeN)F)rr r!r5rrrrr	r6esr6c@seZdZdZdS)�StreamWriterz-Combination of hexlify codec and StreamWriterN)rr r!r5rrrr	r7ksr7c@seZdZdZdS)�StreamReaderz-Combination of hexlify codec and StreamReaderN)rr r!r5rrrr	r8osr8c	Cstjdttttttd�S)zencodings module API�hexlify)�namerr�incrementalencoder�incrementaldecoder�streamwriter�streamreader)�codecs�	CodecInforrr"r6r7r8rrrr	�getregentryssrA)r)r)r5�
__future__rr?rr�	NameError�AttributeError�strr-rrrr"r6r7r8rArrrr	�<module>s 



+

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists