Your IP : 216.73.217.13


Current Path : /snap/certbot/5528/lib/python3.12/site-packages/charset_normalizer/__pycache__/
Upload File :
Current File : //snap/certbot/5528/lib/python3.12/site-packages/charset_normalizer/__pycache__/api.cpython-312.pyc

�

uI�i�����UddlmZddlZddlmZddlmZddlmZm	Z	m
Z
mZddlm
Z
mZmZmZmZddlmZdd	lmZmZdd
lmZmZmZmZmZmZej<d�Zej@�Z!e!jEejFd��gZ$d
e%d<gZ&d
e%d<e
D].Z'	ee'�re$jQe'�ne&jQe'��0e$e&zZ*d
e%d<									d																					dd�Z+									d																					dd�Z,									d																					dd�Z-									d																					dd�Z.y#e)$re&jQe'�Y��wxYw)�)�annotationsN)�PathLike)�BinaryIO�)�coherence_ratio�encoding_languages�mb_encoding_languages�merge_coherence_ratios)�IANA_SUPPORTED�IANA_SUPPORTED_SIMILAR�TOO_BIG_SEQUENCE�TOO_SMALL_SEQUENCE�TRACE)�
mess_ratio)�CharsetMatch�CharsetMatches)�any_specified_encoding�cut_sequence_chunks�	iana_name�identify_sig_or_bom�is_multi_byte_encoding�should_strip_sig_or_bom�charset_normalizerz)%(asctime)s | %(levelname)s | %(message)sz	list[str]�
_mb_supported�
_sb_supported�IANA_SUPPORTED_MB_FIRSTc
�Z�t|ttf�s#tdj	t|����|rBtj}
tjt�tjt�t|�}|dk(r_tjd�|r.tjt�tj
�tt!|dddgd�g�S|�Dtj#td	d
j%|��|D�cgc]}t'|d���}}ng}|�Dtj#tdd
j%|��|D�cgc]}t'|d���}}ng}|||zkr!tj#td|||�d
}|}|d
kDr||z|krt)||z�}t|�t*k}
t|�t,k\}|
r*tj#tdj	|��n+|r)tj#tdj	|��g}|rt/|�nd}|�,|j1|�tj#td|�t3�}g}g}t3�}t3�}i}d}t3�}d}d}d}d}d}d}t�}t�} t5|�\}!}"|!�6|j1|!�tj#tdt|"�|!�|j1d�d|vr|j1d�|t6zD�	]e}#|r|#|vr�|r|#|vr�|#|vr�|j9|#�d}$|!|#k(}%|%xrt;|#�}&|#dvr|%stj#td|#��`|#dvr|%stj#td|#���|#|vrtj#td|#���|#|vrtj#td|#���	t=|#�}'|r[|'st3tC|#��}(nt3tE|#��}(|(jG|�stj#td|#|(|���+|r&|'s$||k\rtj#td|#||���S|r|'stj#td|#���t	|r9|'dur5tI|&dur|dt)d�n|t|"�t)d�|#��nC|#d k(r|%rtI||#��}$|$r-|$dd!k(r%|$d
d}$ntI|&dur|n
|t|"�d|#��}$tO|%sdn
t|"�|t)||z��}*|'xr|$duxrt|$�|k}+|+rtj#td#|#�|$���|'�s�tQ|$�},|jS|,�}-|-���|-\}.}/}0|0�rtt!||#|.|%|/|dus|#|ddfvr|$nd|�$�}1|j1|1�|j9|#�tj#td%|#tU|.d&zd'�(��|#|ddfvry|.d)krt|.dk(r^tjd*|1jV�|r.tjt�tj
�t|1g�cS| j1|1�t| �r||�||vrvd|vrrd|vrn| jY�}2tjd*|2jV�|r.tjt�tj
�t|2g�cS���|j1|#�tj#td+|#�|	r-|#dd|d,d-fvr$t!||#||%g|$|�$�}3|#|k(r|3}n
|#dk(r|3}n|3}��Mt)t|*�d.z�}4t[|4d/�}4d}5d}6g}7g}8	t]||#|*||%|&|"|'|$�	D]g}9|7j1|9�|8j1t_|9||d0uxrd
t|�cxkxrd/knc��|8d1|k\r|5d
z
}5|5|4k\s|%s�b|&dus�gn|6s$|r"|'s 	|t)d3�dja|#d4�5�|8rtc|8�t|8�znd}:|:|k\s|5|4k\r�|j1|#�|#tdvr|jgtd|#�|$� |'s|jitQ|$�|:gdf�tj#td7|#|5tU|:d&zd'�(��|	r/|#dd|d,d-fvr&|6s$t!||#||%g|$|�$�}3|#|k(r|3}n
|#dk(r|3}n|3}���tj#td8|#tU|:d&zd'�(��|'stC|#�};ntE|#�};|;r3tj#td9j	|#tI|;���g}<|#dk7rD|7D]3}9tk|9||;rd:j%|;�nd�}=|<j1|=��5tm|<�}>ntm|<�}>|>r*tj#td;j	|>|#��t!||#|:|%|>|dus|#|ddfvr|$nd|�$�}?|j1|?�|$� |'s|jitQ|$�|:|>d0f�|r|'s
|:d<kr|d
z
}|#|ddfvry|:d)krt|:dk(r^tjd*|?jV�|r.tjt�tj
�t|?g�cS| j1|?�t| �r||�||vrvd|vrrd|vrn| jY�}2tjd*|2jV�|r.tjt�tj
�t|2g�cS|sW|'sU|>rt[d=�|>D�d�>�nd}@|@d?k\r8d|vr4d|vr0d0}|jg|;�tj#td@|#|:@�|s\|'rZ|+rX|$�Vt|$�|dAzkrE|#dBvrAd|vr=d|vr9d0}tj#tdC|#|:t|$�|t|$�|zd&z�|#|!k(s�	�tjdD|#�|r.tjt�tj
�t||#g�cSt|�dk(r�|s|s|rtj#tdE�|r2tjdF|jV�|j1|�nr|r|�|r|r|jn|jnk7s|�'tjdG�|j1|�n(|r&tjdH�|j1|�|r<tjdI|jY�jVt|�d
z
�ntjdJ�|r.tjt�tj
�|Scc}wcc}w#t>t@f$rtj#td|#�Y�
��wxYw#tJtLf$rQ})t|)tL�s%tj#td"|#tI|)��|j1|#�Yd})~)��Xd})~)wwxYw#tJ$r4})tj#td2|#tI|)��|4}5d0}6Yd})~)���d})~)wwxYw#tJ$rA})tj#td6|#tI|)��|j1|#�Yd})~)���d})~)wwxYw)Kaf
    Given a raw bytes sequence, return the best possibles charset usable to render str objects.
    If there is no results, it is a strong indicator that the source is binary/not text.
    By default, the process will extract 5 blocks of 512o each to assess the mess and coherence of a given sequence.
    And will give up a particular code page after 20% of measured mess. Those criteria are customizable at will.

    The preemptive behavior DOES NOT replace the traditional detection workflow, it prioritize a particular code page
    but never take it for granted. Can improve the performance.

    You may want to focus your attention to some code page or/and not others, use cp_isolation and cp_exclusion for that
    purpose.

    This function will strip the SIG in the payload/sequence every time except on UTF-16, UTF-32.
    By default the library does not setup any handler other than the NullHandler, if you choose to set the 'explain'
    toggle to True it will alter the logger configuration to add a StreamHandler that is suitable for debugging.
    Custom logging format and handler can be set manually.
    z3Expected object of type bytes or bytearray, got: {}rz<Encoding detection on empty bytes, assuming utf_8 intention.�utf_8gF�Nz`cp_isolation is set. use this flag for debugging purpose. limited list of encoding allowed : %s.z, zacp_exclusion is set. use this flag for debugging purpose. limited list of encoding excluded : %s.z^override steps (%i) and chunk_size (%i) as content does not fit (%i byte(s) given) parameters.rz>Trying to detect encoding from a tiny portion of ({}) byte(s).zIUsing lazy str decoding because the payload is quite large, ({}) byte(s).z@Detected declarative mark in sequence. Priority +1 given for %s.�zIDetected a SIG or BOM mark on first %i byte(s). Priority +1 given for %s.�ascii>�utf_16�utf_32z\Encoding %s won't be tested as-is because it require a BOM. Will try some sub-encoder LE/BE.>�utf_7zREncoding %s won't be tested as-is because detection is unreliable without BOM/SIG.zY%s is deemed too similar to a code page that was already considered unsuited. Continuing!zESkipping %s: already fast-tracked from a similar successful encoding.z2Encoding %s does not provide an IncrementalDecoderzbSkipping %s: definitive match already found, this encoding targets different languages (%s vs %s).zXSkipping %s: already accumulated %d same-family results after definitive match (cap=%d).zCSkipping single-byte %s: multi-byte definitive match already found.g��A)�encodingr$uz9Code page %s does not fit given bytes sequence at ALL. %szpCode page %s is a multi byte encoding table and it appear that at least one character was encoded using n-bytes.)�preemptive_declarationzM%s fast-tracked (identical decoded payload to a prior encoding, chaos=%f %%).�d�)�ndigits皙�����?z.Encoding detection: %s is most likely the one.zZ%s fast-skipped (identical decoded payload to a prior encoding that failed chaos probing).r"r#��T���zaLazyStr Loading: After MD chunk decode, code page %s does not fit given bytes sequence at ALL. %sgj�@�strict)�errorsz^LazyStr Loading: After final lookup, code page %s does not fit given bytes sequence at ALL. %szc%s was excluded because of initial chaos probing. Gave up %i time(s). Computed mean chaos is %f %%.z=%s passed initial chaos probing. Mean measured chaos is %f %%z&{} should target any language(s) of {}�,z We detected language {} using {}g{�G�z�?c3�&K�|]	\}}|���y�w)N�)�.0�_�vs   ��/build/snapcraft-certbot-53a6961353a63169611ae8a78f6bfa4f/parts/certbot/install/lib/python3.12/site-packages/charset_normalizer/api.py�	<genexpr>zfrom_bytes.<locals>.<genexpr>�s����4�4�1�a�Q�4�s�)�defaultg�?zyDefinitive match found: %s (chaos=%.3f, coherence=%.2f). Encodings targeting different language families will be skipped.g\��(\�?>	r$rr"r#�	utf_16_be�	utf_16_le�	utf_32_be�	utf_32_le�	utf_8_sigzjMulti-byte definitive match: %s (chaos=%.3f, decoded=%d/%d=%.1f%%). Single-byte encodings will be skipped.zoEncoding detection: %s is most likely the one as we detected a BOM or SIG within the beginning of the sequence.zONothing got out of the detection process. Using ASCII/UTF-8/Specified fallback.z7Encoding detection: %s will be used as a fallback matchz:Encoding detection: utf_8 will be used as a fallback matchz:Encoding detection: ascii will be used as a fallback matchz]Encoding detection: Found %s as plausible (best-candidate) for content. With %i alternatives.z=Encoding detection: Unable to determine any suitable charset.)8�
isinstance�	bytearray�bytes�	TypeError�format�type�logger�level�
addHandler�explain_handler�setLevelr�len�debug�
removeHandlerrr�log�joinr�intrr
r�append�setrr�addrr�ModuleNotFoundError�ImportErrorrr	�intersection�str�UnicodeDecodeError�LookupError�range�hash�get�roundr%�best�maxrr�decode�sumr�update�
setdefaultrr
�fingerprint)A�	sequences�steps�
chunk_size�	threshold�cp_isolation�cp_exclusion�preemptive_behaviour�explain�language_threshold�enable_fallback�previous_logger_level�length�cp�is_too_small_sequence�is_too_large_sequence�prioritized_encodings�specified_encoding�tested�tested_but_hard_failure�tested_but_soft_failure�soft_failure_skip�success_fast_tracked�payload_result_cache�definitive_match_found�definitive_target_languages� post_definitive_sb_success_count�POST_DEFINITIVE_SB_CAP�mb_definitive_match_found�fallback_ascii�fallback_u8�fallback_specified�results�early_stop_results�sig_encoding�sig_payload�
encoding_iana�decoded_payload�bom_or_sig_available�strip_sig_or_bom�is_multi_byte_decoder�
enc_languages�e�r_�multi_byte_bonus�payload_hash�cached�cached_mess�	cached_cd�
cached_passed�
fast_match�probable_result�fallback_entry�max_chunk_gave_up�early_stop_count�lazy_str_hard_failure�	md_chunks�	md_ratios�chunk�mean_mess_ratio�target_languages�	cd_ratios�chunk_languages�cd_ratios_merged�
current_match�best_coherencesA                                                                 r6�
from_bytesr�9sF��<�i�)�U�!3�4��A�H�H��Y��
�
�	
��%+�\�\�����/�*�������i�.�F�
��{����S�T��� � ��1��O�O�1�2��|�I�w��U�B�PR�S�T�U�U����
�
��
5��I�I�l�#�		
�8D�D��	�"�e�,�D��D������
�
��
6��I�I�l�#�		
�8D�D��	�"�e�,�D��D���
�*�u�$�%��
�
��l����	
����
��q�y�V�e�^�j�0���%��(�
�"%�i�.�3E�"E��"%�i�.�4D�"D����
�
��L�S�S��
�	
�
��
�
��W�^�^��
�	
�(*��.B��y�)�t���%��$�$�%7�8��
�
��N��	
��u�F�)+��)+��"%�%��%(�U��
TV��$)��,/�E��-.�$�"#��',��*.�N�'+�K�.2��,�.�G�)7�)9�� 3�I� >��L�+����$�$�\�2��
�
��W�����		
�� � ��)��+�+��$�$�W�-�.�1H�H�D	<�
��M��=���M�\�9���F�"���
�
�=�!�&*��%1�]�%B��!5�"
�:Q��;
���0�0�9M��J�J��n��
�

��I�%�.B��J�J��d��
�

��-�-��J�J��k��
�

��0�0��J�J��W��
�

�	�*@��*O�!�"�(� #�$6�}�$E� F�
� #�$9�-�$H� I�
� �-�-�.I�J��
�
��x�!�!�/���
#�)�0�4J�J��J�J��j��0�&�
�
�
%�-B��J�J��U��
�

�*	�$�)>�%�)G��,�u�4�"�+�C��I�.�&�s�;�'7�#�d�)�D�*�
�!�G�+�0D�&)�!�!.�'�O�'�?�1�+=��+I�*9�!�"�*=��&)� 0�5�8�&�!*�3�{�+;�+=�!>�!.�
'�O�&�)�A�s�;�/?�������
��
"�
.��t�+�
.��O�$�v�-�	���J�J��-��	
��&�/D� $�_� 5�L�)�-�-�l�;�F��!�8>�5��Y�
� �!-�!�%�#�,�!�!6�� >�#0�$6���#I�$J�,�"&�/A�"�J�"�N�N�:�.�(�,�,�]�;��J�J��g�%��k�C�/��;�	�&�*<�g�w�)O�O�'�#�-�&�#�-�"�L�L� P� *� 3� 3�� '� &� 4� 4�_� E� &���0E� F�#1�:�,�#?�?�*�1�1�*�=��.�/�/�7�;M�QW�;W�#�v�-�#�v�-�8J�8O�8O�8Q�����L�+�4�4��#�"�0�0��A�"�O�O�,A�B�-��.?�@�@��,�2�2�=�A��J�J��t�%��'�=���*� � �=�,�*6�%�)�%�0��+�3E�*��)�,>�>�1?�.�*�g�5�-;�N�*8�K��!$�S��W�q�[�!1��� 1�1�5�� !�� %��!�	��	�'	)�,�����$� ��%��
�
��� � ��'�� � ���!��4��G�A��\�1B�,G�a�,G����R�=�I�-�$��)�$�$�(9�9�(�-=��-F��7
�V&�%�)�

��#�d�)�+�&�-�-�m�H�-�M�EN��Y��#�i�.�!@�SV���i�'�+;�?P�+P�#�*�*�=�9�� 6�6�!�(�(�)?�
�)N�O��*�3H�$�/�/���)�O�R��+G��
�J�J��0�� ��o��+�Q�7�

� �!��W�&8�(�H�M�N�-�!-��!��(��#�+=�"��!�$6�6�)7�&�"�g�-�%3�N�"0�K���
�
��K���/�C�'��3�		
�%�*<�]�*K��4�]�C����J�J��8�?�?�!�3�'7�#8��
��	��G�#�#�
2��"1��&�2B�C�H�H�-�.��#��� � ��1�
2� 6�i�@��5�i�@����J�J��2�9�9�$�m��
�%���� ��*�U�2�$�);�W�g�(N�N� �
�#5�
�
�"	���}�%��&�/D� �+�+��_�%� �"2�D�9�
�
#�)��$�&�,��1�,�
�0�'�7�C�C��#�%��#�%����D�!�*�*����(�(��9��O�O�$9�:�%�}�o�6�6��%�%�m�4�
�"�#�#�+�/A�V�/K��6�!��6�!�0�5�5�7�O��L�L�@��(�(�
���$�$�_�5���� 5�6�!�?�"3�4�4�&�.C�$��4�#3�4�c�B��
�
��$��F�):�w�&�?P�)-�&�+�2�2�3C�D��
�
��P�!�#�"��*�%� ��+��O�$�v��}�4��
���6�!��6�!�(,�%��J�J��|����O�$���O�$�v�-��3�
��L�(��L�L�1��
�
��$�$�_�5���� 5�6�!�7�=�#9�":�;�;�ID	<�L�7�|�q���.�,>��J�J��a�
�
��L�L�I�"�+�+�
�
�N�N�-�.�
�^�3��"��+�+�~�/I�/I�I��'��L�L�U�V��N�N�;�'�
��L�L�U�V��N�N�>�*�����k��L�L�N�#�#���L�1��	
�	���T�U�����_�-����-�.��N��UE��E��L$�[�1�	��J�J��D��
�

�
	��t#�K�0�		��a��-��
�
��O�!���F�	�
$�*�*�=�9���		��X
�
	)�
�J�J��s���A��	
� 1��$(�!��
	)��*&�
��
�
��t�!���F�	�(�.�.�}�=���
�su�x�%x�x�5A>x=�9A4z �.z �3z �={ �*x:�9x:�=z�Az�z� 	{�)){�{� 	|*�)6|%�%|*c
�F�t|j�|||||||||	�
S)z�
    Same thing than the function from_bytes but using a file pointer that is already ready.
    Will not close the file pointer.
    )r��read)
�fprdrerfrgrhrirjrkrls
          r6�from_fpr�`s5�� �
���	�
�����������c

�n�t|d�5}
t|
|||||||||	�
cddd�S#1swYyxYw)z�
    Same thing than the function from_bytes but with one extra step. Opening and reading given file path in binary mode.
    Can raise IOError.
    �rbN)�openr�)�pathrdrerfrgrhrirjrkrlr�s           r6�	from_pathr�~sK�� 
�d�D�	�
�R�������� ����
�
�
�
�s�+�4c
���t|ttf�rt||||||||||	��
}
|
St|tt
f�rt
||||||||||	��
}
|
St||||||||||	��
}
|
S)a)
    Detect if the given input (file, bytes, or path) points to a binary file. aka. not a string.
    Based on the same main heuristic algorithms and default kwargs at the sole exception that fallbacks match
    are disabled to be stricter around ASCII-compatible but unlikely to be a string.
    )	rdrerfrgrhrirjrkrl)r>rUrr�r@r?r�r�)�fp_or_path_or_payloadrdrerfrgrhrirjrkrl�guessess           r6�	is_binaryr��s���"�'�#�x��9��!��!��%�%�!5��1�+�
��Z�;��C
����	
�
��!��!��%�%�!5��1�+�
��4�;���!��!��%�%�!5��1�+�
���;�r�)	��皙�����?NNTFr*T)rczbytes | bytearrayrdrNrerNrf�floatrg�list[str] | Nonerhr�ri�boolrjr�rkr�rlr��returnr)r�rrdrNrerNrfr�rgr�rhr�rir�rjr�rkr�rlr�r�r)r�zstr | bytes | PathLikerdrNrerNrfr�rgr�rhr�rir�rjr�rkr�rlr�r�r)	r�r�r�NNTFr*F)r�z!PathLike | str | BinaryIO | bytesrdrNrerNrfr�rgr�rhr�rir�rjr�rkr�rlr�r�r�)/�
__future__r�logging�osr�typingr�cdrrr	r
�constantrrr
rr�mdr�modelsrr�utilsrrrrrr�	getLoggerrD�
StreamHandlerrG�setFormatter�	Formatterr�__annotations__r�_supported_encrOrSrr�r�r�r�r2r�r6�<module>r�s;��"���������0���
��	�	�/�	0��'�'�'�'�)������G���A�B���
�y���
�y��$�-�N�-�!�.�1�� � ��0�� � ��0��-�&3�]�%B���B�
���%)�%)�!%�� #� �d� �d��d��d��	d�
#�d�#�
d��d��d��d��d��d�R���%)�%)�!%�� #� ���������	�
#��#�
�����������@���%)�%)�!%�� #� �
�
 �
��
��
��	
�
#�
�#�

��
��
��
��
��
�B���%)�%)�!%�� #�!�?�<�?��?��?��	?�
#�?�#�
?��?��?��?��?�
�?��U�-����^�,�-�s�(+E,�,F�F