HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/site-packages/charset_normalizer/__pycache__/models.cpython-37.pyc
B

���gj0�@s�ddlmZddlmZddlmZddlmZddlm	Z	ddl
mZmZm
Z
mZddlmZmZdd	lmZmZmZGd
d�d�ZGdd
�d
�ZeeefZe
eZGdd�d�ZdS)�)�annotations)�aliases)�sha256)�dumps)�sub)�Any�Iterator�List�Tuple�)�RE_POSSIBLE_ENCODING_INDICATION�TOO_BIG_SEQUENCE)�	iana_name�is_multi_byte_encoding�
unicode_rangec	@s�eZdZdAdddddddd�d	d
�Zddd�d
d�Zddd�dd�Zedd�dd��Zdd�dd�Zdd�dd�Z	ddd�dd�Z
edd�dd��Zedd�dd��Zedd�d d!��Z
edd�d"d#��Zedd�d$d%��Zedd�d&d'��Zedd�d(d)��Zedd�d*d+��Zedd�d,d-��Zedd�d.d/��Zedd�d0d1��Zed2d�d3d4��Zedd�d5d6��Zedd�d7d8��Zedd�d9d:��ZdBddd<�d=d>�Zedd�d?d@��ZdS)C�CharsetMatchN�bytes�str�float�bool�CoherenceMatchesz
str | None)�payload�guessed_encoding�mean_mess_ratio�has_sig_or_bom�	languages�decoded_payload�preemptive_declarationcCsL||_||_||_||_||_d|_g|_d|_d|_d|_	||_
||_dS)Ng)�_payload�	_encoding�_mean_mess_ratio�
_languages�_has_sig_or_bom�_unicode_ranges�_leavesZ_mean_coherence_ratio�_output_payload�_output_encoding�_string�_preemptive_declaration)�selfrrrrrrr�r*�C/usr/local/lib/python3.7/site-packages/charset_normalizer/models.py�__init__s
zCharsetMatch.__init__�object)�other�returncCs>t|t�s&t|t�r"t|�|jkSdS|j|jko<|j|jkS)NF)�
isinstancerrr�encoding�fingerprint)r)r.r*r*r+�__eq__*s


zCharsetMatch.__eq__cCs�t|t�st�t|j|j�}t|j|j�}|dkrJ|dkrJ|j|jkS|dkr�|dkr�t|j�tkrt|j|jkS|j	|j	kS|j|jkS)zQ
        Implemented to make sorted available upon CharsetMatches items.
        g{�G�z�?g{�G�z�?)
r0r�
ValueError�abs�chaos�	coherence�lenrr
�multi_byte_usage)r)r.Zchaos_differenceZcoherence_differencer*r*r+�__lt__1s
zCharsetMatch.__lt__)r/cCsdtt|��t|j�S)Ng�?)r8r�raw)r)r*r*r+r9GszCharsetMatch.multi_byte_usagecCs"|jdkrt|j|jd�|_|jS)N�strict)r'rrr)r)r*r*r+�__str__Ks
zCharsetMatch.__str__cCsd|j�d|j�d�S)Nz<CharsetMatch 'z' bytes(z)>)r1r2)r)r*r*r+�__repr__QszCharsetMatch.__repr__�NonecCs8t|t�r||kr"td�|j���d|_|j�|�dS)Nz;Unable to add instance <{}> as a submatch of a CharsetMatch)r0rr4�format�	__class__r'r$�append)r)r.r*r*r+�add_submatchTs
zCharsetMatch.add_submatchcCs|jS)N)r)r)r*r*r+r1_szCharsetMatch.encodingz	list[str]cCsHg}x>t��D]2\}}|j|kr,|�|�q|j|kr|�|�qW|S)z�
        Encoding name are known by many name, using this could help when searching for IBM855 when it's listed as CP855.
        )r�itemsr1rB)r)Z
also_known_as�u�pr*r*r+�encoding_aliasescs

zCharsetMatch.encoding_aliasescCs|jS)N)r")r)r*r*r+�bompszCharsetMatch.bomcCs|jS)N)r")r)r*r*r+�byte_order_marktszCharsetMatch.byte_order_markcCsdd�|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'.
        cSsg|]}|d�qS)rr*)�.0�er*r*r+�
<listcomp>~sz*CharsetMatch.languages.<locals>.<listcomp>)r!)r)r*r*r+rxszCharsetMatch.languagescCsp|jsbd|jkrdSddlm}m}t|j�r8||j�n||j�}t|�dksVd|krZdS|dS|jddS)z�
        Most probable language found in decoded sequence. If none were detected or inferred, the property will return
        "Unknown".
        �asciiZEnglishr)�encoding_languages�mb_encoding_languageszLatin Based�Unknown)r!�could_be_from_charsetZcharset_normalizer.cdrNrOrr1r8)r)rNrOrr*r*r+�language�s

zCharsetMatch.languagecCs|jS)N)r )r)r*r*r+r6�szCharsetMatch.chaoscCs|js
dS|jddS)Ngrr)r!)r)r*r*r+r7�szCharsetMatch.coherencecCst|jddd�S)N�d�)�ndigits)�roundr6)r)r*r*r+�
percent_chaos�szCharsetMatch.percent_chaoscCst|jddd�S)NrSrT)rU)rVr7)r)r*r*r+�percent_coherence�szCharsetMatch.percent_coherencecCs|jS)z+
        Original untouched bytes.
        )r)r)r*r*r+r;�szCharsetMatch.rawzlist[CharsetMatch]cCs|jS)N)r$)r)r*r*r+�submatch�szCharsetMatch.submatchcCst|j�dkS)Nr)r8r$)r)r*r*r+�has_submatch�szCharsetMatch.has_submatchcCs@|jdk	r|jSdd�t|�D�}ttdd�|D���|_|jS)NcSsg|]}t|��qSr*)r)rJ�charr*r*r+rL�sz*CharsetMatch.alphabets.<locals>.<listcomp>cSsh|]}|r|�qSr*r*)rJ�rr*r*r+�	<setcomp>�sz)CharsetMatch.alphabets.<locals>.<setcomp>)r#r�sorted�list)r)Zdetected_rangesr*r*r+�	alphabets�s

zCharsetMatch.alphabetscCs|jgdd�|jD�S)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'.
        cSsg|]
}|j�qSr*)r1)rJ�mr*r*r+rL�sz6CharsetMatch.could_be_from_charset.<locals>.<listcomp>)rr$)r)r*r*r+rQ�sz"CharsetMatch.could_be_from_charset�utf_8)r1r/cs~�jdks�j|krx|�_t��}�jdk	rj�j��dkrjtt�fdd�|dd�dd�}||dd�}|�|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�utf8rbcs<|j|��d|��d��|��dt�j��dd��S)Nrr�_�-)�string�span�replace�groupsrr&)ra)r)r*r+�<lambda>�s
z%CharsetMatch.output.<locals>.<lambda>i r)�countrh)r&rr(�lowerrr�encoder%)r)r1�decoded_stringZpatched_headerr*)r)r+�output�s


zCharsetMatch.outputcCst|�����S)zw
        Retrieve the unique SHA256 computed using the transformed (re-encoded) payload. Not the original one.
        )rro�	hexdigest)r)r*r*r+r2�szCharsetMatch.fingerprint)NN)rb)�__name__�
__module__�__qualname__r,r3r:�propertyr9r=r>rCr1rGrHrIrrRr6r7rWrXr;rYrZr`rQror2r*r*r*r+r
s2

	rc@s�eZdZdZddd�dd�Zdd�d	d
�Zddd
�dd�Zdd�dd�Zdd�dd�Zddd
�dd�Z	dd�dd�Z
dd�dd�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.
    Nzlist[CharsetMatch] | None)�resultscCs|rt|�ng|_dS)N)r^�_results)r)rvr*r*r+r,�szCharsetMatches.__init__zIterator[CharsetMatch])r/ccs|jEdHdS)N)rw)r)r*r*r+�__iter__�szCharsetMatches.__iter__z	int | strr)�itemr/cCsNt|t�r|j|St|t�rFt|d�}x|jD]}||jkr0|Sq0Wt�dS)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.
        FN)r0�intrwrrrQ�KeyError)r)ry�resultr*r*r+�__getitem__s




zCharsetMatches.__getitem__rzcCs
t|j�S)N)r8rw)r)r*r*r+�__len__szCharsetMatches.__len__rcCst|j�dkS)Nr)r8rw)r)r*r*r+�__bool__szCharsetMatches.__bool__r?cCs~t|t�std�t|j����t|j�tkrbx4|j	D]*}|j
|j
kr4|j|jkr4|�|�dSq4W|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)r0rr4r@rrAr8r;r
rwr2r6rCrBr^)r)ry�matchr*r*r+rBs

zCharsetMatches.appendzCharsetMatch | NonecCs|js
dS|jdS)zQ
        Simply return the first match. Strict equivalent to matches[0].
        Nr)rw)r)r*r*r+�best)szCharsetMatches.bestcCs|��S)zP
        Redundant method, call the method best(). Kept for BC reasons.
        )r�)r)r*r*r+�first1szCharsetMatches.first)N)rqrrrs�__doc__r,rxr}r~rrBr�r�r*r*r*r+ru�sruc@sNeZdZdddddddddddd�dd�Zed	d
�dd��Zdd
�d
d�ZdS)�CliDetectionResultrz
str | Nonez	list[str]rr)�pathr1rG�alternative_encodingsrRr`rr6r7�unicode_path�is_preferredcCsF||_|
|_||_||_||_||_||_||_||_|	|_	||_
dS)N)r�r�r1rGr�rRr`rr6r7r�)r)r�r1rGr�rRr`rr6r7r�r�r*r*r+r,=szCliDetectionResult.__init__zdict[str, Any])r/cCs2|j|j|j|j|j|j|j|j|j|j	|j
d�S)N)r�r1rGr�rRr`rr6r7r�r�)r�r1rGr�rRr`rr6r7r�r�)r)r*r*r+�__dict__WszCliDetectionResult.__dict__cCst|jddd�S)NT�)�ensure_ascii�indent)rr�)r)r*r*r+�to_jsongszCliDetectionResult.to_jsonN)rqrrrsr,rtr�r�r*r*r*r+r�<s"r�N)�
__future__rZencodings.aliasesr�hashlibr�jsonr�rer�typingrrr	r
Zconstantrr
�utilsrrrrrurrZCoherenceMatchrr�r*r*r*r+�<module>siC