HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /lib/python3/dist-packages/serial/tools/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/serial/tools/__pycache__/hexlify_codec.cpython-311.pyc
�

��^]��(�dZddlmZddlZddlZ	en#eef$reZYnwxYwdZ	dd�Z
dd�ZGd�d	ej��ZGd
�dej
��Z
Gd�d
ej��ZGd�deej��ZGd�deej��Zd�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_importN�0123456789ABCDEF�strictc��tjd�|���D����t|��fS)�'40 41 42' -> b'@ab'c�.�g|]}t|d����S����int��.0�hs  �</usr/lib/python3/dist-packages/serial/tools/hexlify_codec.py�
<listcomp>zhex_encode.<locals>.<listcomp>(s ��>�>�>�A�S��B�Z�Z�>�>�>�)�serial�to_bytes�split�len��data�errorss  r�
hex_encoder&s4���O�>�>������>�>�>�?�?��T���K�Krc��td�d�tj|��D������t	|��fS)�b'@ab' -> '40 41 42'�c3�ZK�|]&}d�t|����V��'dS�z{:02X} N��format�ord�r�bs  r�	<genexpr>zhex_decode.<locals>.<genexpr>-s6����U�U��I�,�,�S��V�V�4�4�U�U�U�U�U�Ur)�unicode�joinr�	iterbytesrrs  r�
hex_decoder)+sE���B�G�G�U�U�f�>N�t�>T�>T�U�U�U�U�U�V�V�X[�\`�Xa�Xa�b�brc��eZdZdd�Zdd�ZdS)�Codecrc�b�tjd�|���D����S)rc�.�g|]}t|d����Sr	rr
s  rrz Codec.encode.<locals>.<listcomp>3s ��A�A�A�q��A�r�
�
�A�A�Ar)rrr��selfrrs   r�encodezCodec.encode1s)����A�A�D�J�J�L�L�A�A�A�B�B�Brc�~�td�d�tj|��D������S)rrc3�ZK�|]&}d�t|����V��'dSrr r#s  rr%zCodec.decode.<locals>.<genexpr>7�6����X�X�A�y�/�/��A���7�7�X�X�X�X�X�Xr�r&r'rr(r.s   r�decodezCodec.decode5s7���r�w�w�X�X��AQ�RV�AW�AW�X�X�X�X�X�Y�Y�YrN�r)�__name__�
__module__�__qualname__r0r5�rrr+r+0sF������C�C�C�C�Z�Z�Z�Z�Z�Zrr+c�4�eZdZdZd
d�Zd�Zd�Zd�Zdd�Zd	S)�IncrementalEncoderzIncremental hex encoderrc�"�||_d|_dS�Nr)r�state)r/rs  r�__init__zIncrementalEncoder.__init__=s�������
�
�
rc��d|_dSr>�r?�r/s r�resetzIncrementalEncoder.resetAs
����
�
�
rc��|jS�NrBrCs r�getstatezIncrementalEncoder.getstateDs
���z�rc��||_dSrFrB)r/r?s  r�setstatezIncrementalEncoder.setstateGs
����
�
�
rFc��|j}g}|���D]�}|tvrCt�|��}|r|�||dzz��d}�Ed|dzz}�N|dkr|r|jdkrt
d���d}�s|jdkr"t
d�|�������||_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�UnicodeErrorr!rr)r/r�finalr?�encoded�c�zs       rr0zIncrementalEncoder.encodeJs����
���������	N�	N�A��I�~�~��O�O�A�&�&���-��N�N�1����#5�6�6�6��E�E�!�Q�!�V�,�E�E��c����C�T�[�H�4�4�&�'A�B�B�B�����;�(�*�*�&�'B�'I�'I�!�'L�'L�M�M�M�+���
���w�'�'�'rNr6�F)	r7r8r9�__doc__r@rDrGrIr0r:rrr<r<:so������!�!��������������(�(�(�(�(�(rr<c��eZdZdZdd�ZdS)�IncrementalDecoderzIncremental decoderFc�~�td�d�tj|��D������S)Nrc3�ZK�|]&}d�t|����V��'dSrr r#s  rr%z,IncrementalDecoder.decode.<locals>.<genexpr>hr3rr4)r/rrTs   rr5zIncrementalDecoder.decodegs7���r�w�w�X�X��AQ�RV�AW�AW�X�X�X�X�X�Y�Y�YrNrX)r7r8r9rYr5r:rrr[r[es4��������Z�Z�Z�Z�Z�Zrr[c��eZdZdZdS)�StreamWriterz-Combination of hexlify codec and StreamWriterN�r7r8r9rYr:rrr_r_k�������7�7�7�7rr_c��eZdZdZdS)�StreamReaderz-Combination of hexlify codec and StreamReaderNr`r:rrrcrcorarrcc	�t�tjdtttt
tt���S)zencodings module API�hexlify)�namer0r5�incrementalencoder�incrementaldecoder�streamwriter�streamreader)�codecs�	CodecInforr)r<r[r_rcr:rr�getregentryrmss1����
���-�-�!�!�	�	�	�	rr6)rY�
__future__rrkrr&�	NameError�AttributeError�strrPrr)r+r<r[r_rcrmr:rr�<module>rrs���
�
�'�&�&�&�&�&�
�
�
�
�
�
�
�
���G�G���>�"�����G�G�G�����
�	�
L�L�L�L�
c�c�c�c�
Z�Z�Z�Z�Z�F�L�Z�Z�Z�((�((�((�((�((��2�((�((�((�VZ�Z�Z�Z�Z��2�Z�Z�Z�8�8�8�8�8�5�&�-�8�8�8�8�8�8�8�8�5�&�-�8�8�8�����s��	!�!