Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/charset_normalizer/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/charset_normalizer/__pycache__/models.cpython-312.pyc

�

'ٜgj0����ddlmZddlmZddlmZddlmZddlm	Z	ddl
mZmZm
Z
mZddlmZmZdd	lmZmZmZGd
�d�ZGd�d
�ZeeefZe
eZGd�d�Zy)�)�annotations)�aliases)�sha256)�dumps)�sub)�Any�Iterator�List�Tuple�)�RE_POSSIBLE_ENCODING_INDICATION�TOO_BIG_SEQUENCE)�	iana_name�is_multi_byte_encoding�
unicode_rangec��eZdZ		d													dd�Zdd�Zdd�Zedd��Zdd�Zdd�Z	dd�Z
edd	��Zed d
��Zed!d��Z
ed!d��Zed d
��Zedd��Zedd��Zedd��Zedd��Zedd��Zed"d��Zed#d��Zed!d��Zed d��Zed d��Zd$d%d�Zedd��Zy)&�CharsetMatchNc��||_||_||_||_||_d|_g|_d|_d|_d|_	||_
||_y)N�)�_payload�	_encoding�_mean_mess_ratio�
_languages�_has_sig_or_bom�_unicode_ranges�_leaves�_mean_coherence_ratio�_output_payload�_output_encoding�_string�_preemptive_declaration)�self�payload�guessed_encoding�mean_mess_ratio�has_sig_or_bom�	languages�decoded_payload�preemptive_declarations        �D/usr/local/lib/python3.12/site-packages/charset_normalizer/models.py�__init__zCharsetMatch.__init__s_�� '��
�.���'6���,5���%3���15���+-���,/��"�-1���,0���#2���3I��$�c���t|t�s)t|t�rt|�|jk(Sy|j|jk(xr|j
|j
k(S)NF)�
isinstancer�strr�encoding�fingerprint�r"�others  r*�__eq__zCharsetMatch.__eq__*sV���%��.��%��%� ��'�4�=�=�8�8���}�}����.�X�4�3C�3C�u�GX�GX�3X�Xr,c���t|t�st�t|j|jz
�}t|j
|j
z
�}|dkr|dkDr|j
|j
kDS|dkrS|dkrNt
|j�tk\r|j|jkS|j|jkDS|j|jkS)zQ
        Implemented to make sorted available upon CharsetMatches items.
        g{�G�z�?g{�G�z�?)
r.r�
ValueError�abs�chaos�	coherence�lenrr�multi_byte_usage)r"r3�chaos_difference�coherence_differences    r*�__lt__zCharsetMatch.__lt__1s����%��.���"%�d�j�j�5�;�;�&>�"?��&)�$�.�.�5�?�?�*J�&K���d�"�';�d�'B��>�>�E�O�O�3�3�
��
$�)=��)E��4�=�=�!�%5�5��z�z�E�K�K�/�/��(�(�5�+A�+A�A�A��z�z�E�K�K�'�'r,c�\�dtt|��t|j�zz
S)Ng�?)r:r/�raw�r"s r*r;zCharsetMatch.multi_byte_usageGs"���c�#�d�)�n�s�4�8�8�}�4�5�5r,c�~�|j�&t|j|jd�|_|jS)N�strict)r r/rrrAs r*�__str__zCharsetMatch.__str__Ks.���<�<���t�}�}�d�n�n�h�G�D�L��|�|�r,c�<�d|j�d|j�d�S)Nz<CharsetMatch 'z' bytes(z)>)r0r1rAs r*�__repr__zCharsetMatch.__repr__Qs"�� �����x��8H�8H�7I��L�Lr,c��t|t�r||k(r$tdj|j���d|_|jj|�y)Nz;Unable to add instance <{}> as a submatch of a CharsetMatch)r.rr6�format�	__class__r r�appendr2s  r*�add_submatchzCharsetMatch.add_submatchTsO���%��.�%�4�-��M�T�T��O�O���
���
������E�"r,c��|jS�N)rrAs r*r0zCharsetMatch.encoding_s���~�~�r,c���g}tj�D]G\}}|j|k(r|j|��'|j|k(s�7|j|��I|S)z�
        Encoding name are known by many name, using this could help when searching for IBM855 when it's listed as CP855.
        )r�itemsr0rJ)r"�
also_known_as�u�ps    r*�encoding_aliaseszCharsetMatch.encoding_aliasescsY��
$&�
��M�M�O�D�A�q��}�}��!��$�$�Q�'����!�#��$�$�Q�'�	$�
�r,c��|jSrM�rrAs r*�bomzCharsetMatch.bomp����#�#�#r,c��|jSrMrUrAs r*�byte_order_markzCharsetMatch.byte_order_marktrWr,c�F�|jD�cgc]}|d��	c}Scc}w)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'.
        r�r)r"�es  r*r'zCharsetMatch.languagesxs$��#�o�o�.�o���!��o�.�.��.s�c��|jshd|jvryddlm}m}t|j�r||j�n||j�}t|�dk(sd|vry|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.cdr`rarr0r:)r"r`rar's    r*�languagezCharsetMatch.language�s�������$�4�4�4� �
X�*�$�-�-�8�&�d�m�m�4�'��
�
�6�
��9�~��"�m�y�&@� ��Q�<�����q�!�!�$�$r,c��|jSrM)rrAs r*r8zCharsetMatch.chaos�s���$�$�$r,c�@�|jsy|jddS)Nrrrr[rAs r*r9zCharsetMatch.coherence�s ���������q�!�!�$�$r,c�6�t|jdzd��S�N�d�)�ndigits)�roundr8rAs r*�
percent_chaoszCharsetMatch.percent_chaos�s���T�Z�Z�#�%�q�1�1r,c�6�t|jdzd��Sri)rmr9rAs r*�percent_coherencezCharsetMatch.percent_coherence�s���T�^�^�c�)�1�5�5r,c��|jS)z+
        Original untouched bytes.
        )rrAs r*r@zCharsetMatch.raw�s��
�}�}�r,c��|jSrM)rrAs r*�submatchzCharsetMatch.submatch�s���|�|�r,c�2�t|j�dkDS�Nr)r:rrAs r*�has_submatchzCharsetMatch.has_submatch�s���4�<�<� �1�$�$r,c���|j�|jSt|�D�cgc]
}t|���}}tt	|D�chc]}|s�|��	c}��|_|jScc}wcc}wrM)rr/r�sorted�list)r"�char�detected_ranges�rs    r*�	alphabetszCharsetMatch.alphabets�sp�����+��'�'�'�MP�QU�Y�,W�Y�T�]�4�-@�Y��,W�%�d��+L��!�!�A��+L�&M�N����#�#�#��-X��+Ls�A0�A5�A5c�p�|jg|jD�cgc]}|j��c}zScc}w)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'.
        )rrr0)r"�ms  r*rcz"CharsetMatch.could_be_from_charset�s0������t�|�|�"D�|�!�1�:�:�|�"D�D�D��"Ds�3c�6���j��j|k7rr|�_t��}�j�=�jj�dvr!t	t
�fd�|ddd��}||ddz}|j
|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)zutf-8�utf8�utf_8c����|j|j�d|j�dj|j�dt	�j
�jdd��S)Nrr�_�-)�string�span�replace�groupsrr)rr"s �r*�<lambda>z%CharsetMatch.output.<locals>.<lambda>�sW���a�h�h�q�v�v�x��{�Q�V�V�X�a�[�A�I�I����
�1�
�!�$�"7�"7�8�@�@��c�J�r,i r)�countr�)rr/r!�lowerrr
�encoder)r"r0�decoded_string�patched_headers`   r*�outputzCharsetMatch.output�s����
� � �(�D�,A�,A�X�,M�$,�D�!� ��Y�N��,�,�8��0�0�6�6�8�1�2�"%�3��#�5�D�)��"��"0�.���2G�!G��#1�#8�#8��9�#M�D� ��#�#�#r,c�P�t|j��j�S)zw
        Retrieve the unique SHA256 computed using the transformed (re-encoded) payload. Not the original one.
        )rr��	hexdigestrAs r*r1zCharsetMatch.fingerprint�s��
�d�k�k�m�$�.�.�0�0r,)NN)r#�bytesr$r/r%�floatr&�boolr'�CoherenceMatchesr(�
str | Noner)r�)r3�object�returnr�)r�r��r�r/)r3rr��None)r��	list[str]�r�r�)r�r�)r�zlist[CharsetMatch])r�)r0r/r�r�)�__name__�
__module__�__qualname__r+r4r>�propertyr;rDrFrKr0rSrVrYr'rer8r9rnrpr@rsrvr}rcr�r1�r,r*rr
s���'+�-1�J��J��J��	J�
�J�$�
J�$�J�!+�J�8Y�(�,�6��6��M�	#������
��
��$��$��$��$��/��/��%��%�6�%��%��%��%�
�2��2��6��6����������%��%��$��$��E��E�$�:�1��1r,rc�R�eZdZdZddd�Zd
d�Zdd�Zdd�Zdd�Zdd�Z	dd	�Z
dd
�Zy)�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.
    Nc�8�|rt|�|_yg|_yrM)rx�_results)r"�resultss  r*r+zCharsetMatches.__init__�s��?F�F�7�O��
�B��
r,c#�8K�|jEd{���y7��wrM�r�rAs r*�__iter__zCharsetMatches.__iter__�s�����=�=� � �s���c���t|t�r|j|St|t�r/t	|d�}|jD]}||j
vs�|cSt�)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�r/rrc�KeyError)r"�item�results   r*�__getitem__zCharsetMatches.__getitem__s[��
�d�C� ��=�=��&�&��d�C� ��T�5�)�D��-�-���6�7�7�7�!�M�(��r,c�,�t|j�SrM�r:r�rAs r*�__len__zCharsetMatches.__len__s���4�=�=�!�!r,c�2�t|j�dkDSrur�rAs r*�__bool__zCharsetMatches.__bool__s���4�=�=�!�A�%�%r,c���t|t�s-tdjt	|j
����t
|j�tkrW|jD]H}|j|jk(s�|j|jk(s�7|j|�y|jj|�t|j�|_	y)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.rr6rHr/rIr:r@rr�r1r8rKrJrx)r"r��matchs   r*rJzCharsetMatches.appends���
�$��-��?�F�F�����'���
��t�x�x�=�+�+������$�$��(8�(8�8�U�[�[�D�J�J�=V��&�&�t�,��'�	
�
�
���T�"��t�}�}�-��
r,c�:�|jsy|jdS)zQ
        Simply return the first match. Strict equivalent to matches[0].
        Nrr�rAs r*�bestzCharsetMatches.best)s���}�}���}�}�Q��r,c�"�|j�S)zP
        Redundant method, call the method best(). Kept for BC reasons.
        )r�rAs r*�firstzCharsetMatches.first1s���y�y�{�r,rM)r�zlist[CharsetMatch] | None)r�zIterator[CharsetMatch])r�z	int | strr�r)r�r�r�)r�rr�r�)r�zCharsetMatch | None)r�r�r��__doc__r+r�r�r�r�rJr�r�r�r,r*r�r��s0���
O�!��"�&�.�( �r,r�c�Z�eZdZ																						dd�Zedd��Zdd�Zy)�CliDetectionResultc��||_|
|_||_||_||_||_||_||_||_|	|_	||_
yrM)�path�unicode_pathr0rS�alternative_encodingsrer}r&r8r9�is_preferred)r"r�r0rSr�rer}r&r8r9r�r�s            r*r+zCliDetectionResult.__init__=sV����	�(4���$,��
�+;���0E��"�%��
�$-���$2���!��
� )���".��r,c��|j|j|j|j|j|j
|j|j|j|j|jd�S)N�r�r0rSr�rer}r&r8r9r�r�r�rAs r*�__dict__zCliDetectionResult.__dict__Wse���I�I��
�
� $� 5� 5�%)�%?�%?��
�
����"�1�1��Z�Z���� �-�-� �-�-�
�	
r,c�2�t|jdd��S)NT�)�ensure_ascii�indent)rr�rAs r*�to_jsonzCliDetectionResult.to_jsongs���T�]�]��a�@�@r,N)r�r/r0r�rSr�r�r�rer/r}r�r&r�r8r�r9r�r�r�r�r�)r�zdict[str, Any]r�)r�r�r�r+r�r�r�r�r,r*r�r�<s���/��/��/�$�	/�
 )�/��
/��/��/��/��/�!�/��/�4�

��

�Ar,r�N)�
__future__r�encodings.aliasesr�hashlibr�jsonr�rer�typingrr	r
r�constantr
r�utilsrrrrr�r/r��CoherenceMatchr�r�r�r,r*�<module>r�sd��"�%����-�-�G�C�C�e1�e1�P@�@�F�s�E�z�"����'��,A�,Ar,

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