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/charset_normalizer/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/charset_normalizer/__pycache__/models.cpython-311.pyc
�

�c�,����ddlmZddlmZddlmZddlmZmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZmZmZGd�d	��ZGd
�d��ZeeefZe
eZGd�d
��ZdS)�)�aliases)�sha256)�dumps)�Any�Dict�Iterator�List�Optional�Tuple�Union�)�TOO_BIG_SEQUENCE)�	iana_name�is_multi_byte_encoding�
unicode_rangec��eZdZ	d%dededededddeefd	�Zd
e	defd�Z
d
e	defd
�Zedefd���Z
defd�Zdefd�Zd&d�Zedefd���Zedeefd���Zedefd���Zedefd���Zedeefd���Zedefd���Zedefd���Zedefd���Zedefd���Zedefd���Zedefd���Zededfd���Zedefd���Zedeefd���Zedeefd ���Z d'd"edefd#�Z!edefd$���Z"dS)(�CharsetMatchN�payload�guessed_encoding�mean_mess_ratio�has_sig_or_bom�	languages�CoherenceMatches�decoded_payloadc��||_||_||_||_||_d|_g|_d|_d|_d|_	||_
dS)N�)�_payload�	_encoding�_mean_mess_ratio�
_languages�_has_sig_or_bom�_unicode_ranges�_leaves�_mean_coherence_ratio�_output_payload�_output_encoding�_string)�selfrrrrrrs       �;/usr/lib/python3/dist-packages/charset_normalizer/models.py�__init__zCharsetMatch.__init__s[�� '��
�.���'6���,5���%3���48���+-���,/��"�04���/3���&5������other�returnc��t|t��sGtd�t	|j��t	|j�������|j|jko|j|jkS)Nz&__eq__ cannot be invoked on {} and {}.)�
isinstancer�	TypeError�format�str�	__class__�encoding�fingerprint�r(r,s  r)�__eq__zCharsetMatch.__eq__$ss���%��.�.�	��8�?�?����(�(�#�d�n�*=�*=�����
�
�}���.�X�4�3C�u�GX�3X�Xr+c�N�t|t��st�t|j|jz
��}t|j|jz
��}|dkr<|dkr6|dkr |j|jkr|j|jkS|j|jkS|j|jkS)zQ
        Implemented to make sorted available upon CharsetMatches items.
        g{�G�z�?g{�G�z�?r)r/r�
ValueError�abs�chaos�	coherence�multi_byte_usage)r(r,�chaos_difference�coherence_differences    r)�__lt__zCharsetMatch.__lt__-s����%��.�.�	���"%�d�j�5�;�&>�"?�"?��&)�$�.�5�?�*J�&K�&K���d�"�"�';�d�'B�'B��3�&�&�4�>�U�_�+L�+L��,�u�/E�E�E��>�E�O�3�3��z�E�K�'�'r+c�j�dtt|����t|j��zz
S)Ng�?)�lenr2�raw�r(s r)r=zCharsetMatch.multi_byte_usage@s&���S��T���^�^�c�$�(�m�m�3�3�3r+c�^�|j� t|j|jd��|_|jS)N�strict)r'r2rrrDs r)�__str__zCharsetMatch.__str__Ds)���<���t�}�d�n�h�G�G�D�L��|�r+c�B�d�|j|j��S)Nz<CharsetMatch '{}' bytes({})>)r1r4r5rDs r)�__repr__zCharsetMatch.__repr__Js��.�5�5�d�m�T�EU�V�V�Vr+c���t|t��r||kr'td�|j�����d|_|j�|��dS)Nz;Unable to add instance <{}> as a submatch of a CharsetMatch)r/rr9r1r3r'r#�appendr6s  r)�add_submatchzCharsetMatch.add_submatchMsk���%��.�.�	�%�4�-�-��M�T�T��O�����
���
�����E�"�"�"�"�"r+c��|jS�N)rrDs r)r4zCharsetMatch.encodingXs
���~�r+c��g}tj��D]F\}}|j|kr|�|���&|j|kr|�|���G|S)z�
        Encoding name are known by many name, using this could help when searching for IBM855 when it's listed as CP855.
        )r�itemsr4rK)r(�
also_known_as�u�ps    r)�encoding_aliaseszCharsetMatch.encoding_aliases\sn��
$&�
��M�O�O�	(�	(�D�A�q��}��!�!��$�$�Q�'�'�'�'���!�#�#��$�$�Q�'�'�'���r+c��|jSrN�r!rDs r)�bomzCharsetMatch.bomi����#�#r+c��|jSrNrVrDs r)�byte_order_markzCharsetMatch.byte_order_markmrXr+c�$�d�|jD��S)z�
        Return the complete list of possible languages found in decoded sequence.
        Usually not really useful. Returned list may be empty even if 'language' property return something != 'Unknown'.
        c��g|]
}|d��S)r�)�.0�es  r)�
<listcomp>z*CharsetMatch.languages.<locals>.<listcomp>ws��.�.�.���!��.�.�.r+�r rDs r)rzCharsetMatch.languagesqs��/�.�d�o�.�.�.�.r+c��|jshd|jvrdSddlm}m}t|j��r||j��n||j��}t|��dksd|vrdS|dS|jddS)z�
        Most probable language found in decoded sequence. If none were detected or inferred, the property will return
        "Unknown".
        �ascii�Englishr)�encoding_languages�mb_encoding_languageszLatin Based�Unknown)r �could_be_from_charset�charset_normalizer.cdrerfrr4rB)r(rerfrs    r)�languagezCharsetMatch.languageys�����	 ��$�4�4�4� �y�
X�W�W�W�W�W�W�W�*�$�-�8�8�7�%�%�d�m�4�4�4�'�'��
�6�6�
��9�~�~��"�"�m�y�&@�&@� �y��Q�<����q�!�!�$�$r+c��|jSrN)rrDs r)r;zCharsetMatch.chaos�s���$�$r+c�:�|jsdS|jddS)Nrrr
rarDs r)r<zCharsetMatch.coherence�s#����	��3���q�!�!�$�$r+c�4�t|jdzd���S�N�d�)�ndigits)�roundr;rDs r)�
percent_chaoszCharsetMatch.percent_chaos�s���T�Z�#�%�q�1�1�1�1r+c�4�t|jdzd���Srn)rrr<rDs r)�percent_coherencezCharsetMatch.percent_coherence�s���T�^�c�)�1�5�5�5�5r+c��|jS)z+
        Original untouched bytes.
        )rrDs r)rCzCharsetMatch.raw�s��
�}�r+c��|jSrN)r#rDs r)�submatchzCharsetMatch.submatch�s
���|�r+c�2�t|j��dkS�Nr)rBr#rDs r)�has_submatchzCharsetMatch.has_submatch�s���4�<� � �1�$�$r+c��|j�|jSd�t|��D��}ttd�|D������|_|jS)Nc�,�g|]}t|����Sr])r)r^�chars  r)r`z*CharsetMatch.alphabets.<locals>.<listcomp>�s-��0
�0
�0
�$(�M�$���0
�0
�0
r+c��h|]}|�|��Sr]r])r^�rs  r)�	<setcomp>z)CharsetMatch.alphabets.<locals>.<setcomp>�s��+L�+L�+L�!�!�+L�A�+L�+L�+Lr+)r"r2�sorted�list)r(�detected_rangess  r)�	alphabetszCharsetMatch.alphabets�sj����+��'�'�0
�0
�,/��I�I�0
�0
�0
�� &�d�+L�+L��+L�+L�+L�&M�&M�N�N����#�#r+c�6�|jgd�|jD��zS)z�
        The complete list of encoding that output the exact SAME str result and therefore could be the originating
        encoding.
        This list does include the encoding available in property 'encoding'.
        c��g|]	}|j��
Sr])r4)r^�ms  r)r`z6CharsetMatch.could_be_from_charset.<locals>.<listcomp>�s��"D�"D�"D�!�1�:�"D�"D�"Dr+)rr#rDs r)rhz"CharsetMatch.could_be_from_charset�s%�����"D�"D�t�|�"D�"D�"D�D�Dr+�utf_8r4c��|j�|j|kr/||_t|���|d��|_|jS)z�
        Method to get re-encoded bytes payload using given target encoding. Default to UTF-8.
        Any errors will be simply ignored by the encoder NOT replaced.
        N�replace)r&r2�encoder%)r(r4s  r)�outputzCharsetMatch.output�sI��
� �(�D�,A�X�,M�,M�$,�D�!�#&�t�9�9�#3�#3�H�i�#H�#H�D� ��#�#r+c�h�t|��������S)zw
        Retrieve the unique SHA256 computed using the transformed (re-encoded) payload. Not the original one.
        )rr��	hexdigestrDs r)r5zCharsetMatch.fingerprint�s&��
�d�k�k�m�m�$�$�.�.�0�0�0r+rN)r,rr-N)r�)#�__name__�
__module__�__qualname__�bytesr2�float�boolr
r*�objectr7r@�propertyr=rGrIrLr4r	rTrWrZrrjr;r<rsrurCrxr{r�rhr�r5r]r+r)rr
s�������*.�6�6��6��6��	6�
�6�&�
6�"�#��6�6�6�6�2Y�F�Y�t�Y�Y�Y�Y�(�F�(�t�(�(�(�(�&�4�%�4�4�4��X�4�������W�#�W�W�W�W�	#�	#�	#�	#���#�����X���
�$�s�)�
�
�
��X�
��$�T�$�$�$��X�$��$��$�$�$��X�$��/�4��9�/�/�/��X�/��%�#�%�%�%��X�%�6�%�u�%�%�%��X�%��%�5�%�%�%��X�%�
�2�u�2�2�2��X�2��6�5�6�6�6��X�6���U�����X����$�~�.�����X���%�d�%�%�%��X�%��	$�4��9�	$�	$�	$��X�	$��E�t�C�y�E�E�E��X�E�	$�	$�s�	$��	$�	$�	$�	$��1�S�1�1�1��X�1�1�1r+rc���eZdZdZddeeefd�Zdeefd�Z	de
eefdefd�Z
defd	�Zdefd
�Zdeddfd�Zdedfd
�Zdedfd�ZdS)�CharsetMatchesz�
    Container with every CharsetMatch items ordered by default from most probable to the less one.
    Act like a list(iterable) but does not implements all related methods.
    N�resultsc�6�|rt|��ng|_dSrN)r��_results)r(r�s  r)r*zCharsetMatches.__init__�s��?F�,N�F�7�O�O�O�B��
�
�
r+r-c#�$K�|jEd{V��dSrN�r�rDs r)�__iter__zCharsetMatches.__iter__�s&�����=� � � � � � � � � r+�itemc���t|t��r
|j|St|t��r't	|d��}|jD]}||jvr|cS�t�)z�
        Retrieve a single item either by its position or encoding name (alias may be used here).
        Raise KeyError upon invalid index or encoding not present in results.
        F)r/�intr�r2rrh�KeyError)r(r��results   r)�__getitem__zCharsetMatches.__getitem__�sv��
�d�C� � �	'��=��&�&��d�C� � �	"��T�5�)�)�D��-�
"�
"���6�7�7�7�!�M�M�M�8��r+c�*�t|j��SrN�rBr�rDs r)�__len__zCharsetMatches.__len__�s���4�=�!�!�!r+c�2�t|j��dkSrzr�rDs r)�__bool__zCharsetMatches.__bool__�s���4�=�!�!�A�%�%r+c��t|t��s4td�t	|j�������t
|j��tkrB|j	D]:}|j
|j
kr(|j|jkr|�|��dS�;|j	�
|��t|j	��|_	dS)z~
        Insert a single match. Will be inserted accordingly to preserve sort.
        Can be inserted as a submatch.
        z-Cannot append instance '{}' to CharsetMatchesN)r/rr9r1r2r3rBrCrr�r5r;rLrKr�)r(r��matchs   r)rKzCharsetMatches.append�s���
�$��-�-�	��?�F�F����'�'�����
��t�x�=�=�,�,�,���
�
���$��(8�8�8�U�[�D�J�=V�=V��&�&�t�,�,�,��F�F���
���T�"�"�"��t�}�-�-��
�
�
r+rc�.�|jsdS|jdS)zQ
        Simply return the first match. Strict equivalent to matches[0].
        Nrr�rDs r)�bestzCharsetMatches.bests ���}�	��4��}�Q��r+c�*�|���S)zP
        Redundant method, call the method best(). Kept for BC reasons.
        )r�rDs r)�firstzCharsetMatches.firsts���y�y�{�{�r+rN)r�r�r��__doc__r
r	rr*rr�rr�r2r�r�r�r�rKr�r�r]r+r)r�r��s0��������
O�O���l�);� <�O�O�O�O�!�(�<�0�!�!�!�!���c�3�h���L�����"��"�"�"�"�&�$�&�&�&�&�.�<�.�D�.�.�.�.�( �h�~�.� � � � ��x��/������r+r�c��eZdZdedeedeedeededeededed	ed
eedefd�Ze	d
e
eeffd���Zd
efd�Z
dS)�CliDetectionResult�pathr4rT�alternative_encodingsrjr�rr;r<�unicode_path�is_preferredc��||_|
|_||_||_||_||_||_||_||_|	|_	||_
dSrN)r�r�r4rTr�rjr�rr;r<r�)r(r�r4rTr�rjr�rr;r<r�r�s            r)r*zCliDetectionResult.__init__&s\����	�+7���'/��
�+;���0E��"�%��
�$-���$2���!��
� )���".����r+r-c��|j|j|j|j|j|j|j|j|j|j	|j
d�S)N�r�r4rTr�rjr�rr;r<r�r�r�rDs r)�__dict__zCliDetectionResult.__dict__@sO���I��
� $� 5�%)�%?��
���"�1��Z��� �-� �-�
�
�	
r+c�0�t|jdd���S)NT�)�ensure_ascii�indent)rr�rDs r)�to_jsonzCliDetectionResult.to_jsonPs���T�]��a�@�@�@�@r+N)r�r�r�r2r
r	r�r�r*r�rrr�r�r]r+r)r�r�%s�������/��/��3�-�/��s�)�	/�
 $�C�y�/��
/���9�/��/��/��/��s�m�/��/�/�/�/�4�

�$�s�C�x�.�

�

�

��X�

�A��A�A�A�A�A�Ar+r�N)�encodings.aliasesr�hashlibr�jsonr�typingrrrr	r
rr�constantr�utilsrrrrr�r2r��CoherenceMatchrr�r]r+r)�<module>r�sZ��%�%�%�%�%�%�������������D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�&�&�&�&�&�&�C�C�C�C�C�C�C�C�C�C�Q1�Q1�Q1�Q1�Q1�Q1�Q1�Q1�h@�@�@�@�@�@�@�@�F�s�E�z�"����'��,A�,A�,A�,A�,A�,A�,A�,A�,A�,Ar+