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: //opt/osm/venv/lib64/python3.10/site-packages/charset_normalizer/__pycache__/models.cpython-310.pyc
o

=ij0�@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@sHeZdZ		dGdHdd�ZdIdd�ZdIdd�ZedJdd��ZdKdd�ZdKdd�Z	dLdd �Z
edKd!d"��ZedMd$d%��ZedNd&d'��Z
edNd(d)��ZedMd*d+��ZedKd,d-��ZedJd.d/��ZedJd0d1��ZedJd2d3��ZedJd4d5��ZedOd6d7��ZedPd9d:��ZedNd;d<��ZedMd=d>��ZedMd?d@��ZdQdRdCdD�ZedKdEdF��ZdS)S�CharsetMatchN�payload�bytes�guessed_encoding�str�mean_mess_ratio�float�has_sig_or_bom�bool�	languages�CoherenceMatches�decoded_payload�
str | None�preemptive_declarationcCsL||_||_||_||_||_d|_g|_d|_d|_d|_	||_
||_dS)N�)�_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,�G/opt/osm/venv/lib/python3.10/site-packages/charset_normalizer/models.py�__init__s

zCharsetMatch.__init__�other�object�returncCs>t|t�st|t�rt|�|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�}|dkr%|dkr%|j|jkS|dkr@|dkr@t|j�tkr:|j|jkS|j	|j	kS|j|jkS)zQ
        Implemented to make sorted available upon CharsetMatches items.
        g{�G�z�?g{�G�z�?)
r2r�
ValueError�abs�chaos�	coherence�lenr r
�multi_byte_usage)r+r/Zchaos_differenceZcoherence_differencer,r,r-�__lt__1s
zCharsetMatch.__lt__cCsdtt|��t|j�S)Ng�?)r;r�raw�r+r,r,r-r<GszCharsetMatch.multi_byte_usagecCs"|jdurt|j|jd�|_|jS)N�strict)r)rr r!r?r,r,r-�__str__Ks
zCharsetMatch.__str__cCsd|j�d|j�d�S)Nz<CharsetMatch 'z' bytes(z)>)r3r4r?r,r,r-�__repr__QszCharsetMatch.__repr__�NonecCs8t|t�r	||krtd�|j���d|_|j�|�dS)Nz;Unable to add instance <{}> as a submatch of a CharsetMatch)r2rr7�format�	__class__r)r&�appendr5r,r,r-�add_submatchTs��zCharsetMatch.add_submatchcC�|jS�N)r!r?r,r,r-r3_�zCharsetMatch.encoding�	list[str]cCsDg}t��D]\}}|j|kr|�|�q|j|kr|�|�q|S)z�
        Encoding name are known by many name, using this could help when searching for IBM855 when it's listed as CP855.
        )r�itemsr3rF)r+Z
also_known_as�u�pr,r,r-�encoding_aliasescs


�zCharsetMatch.encoding_aliasescCrHrI�r$r?r,r,r-�bomprJzCharsetMatch.bomcCrHrIrPr?r,r,r-�byte_order_marktrJzCharsetMatch.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>~�z*CharsetMatch.languages.<locals>.<listcomp>�r#r?r,r,r-rxszCharsetMatch.languagescCsp|js1d|jvr
dSddlm}m}t|j�r||j�n||j�}t|�dks+d|vr-dS|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.cdrYrZrr3r;)r+rYrZrr,r,r-�language�s
��zCharsetMatch.languagecCrHrI)r"r?r,r,r-r9�rJzCharsetMatch.chaoscCs|jsdS|jddS)NrrrrWr?r,r,r-r:�szCharsetMatch.coherencecC�t|jddd�S�N�d�)�ndigits)�roundr9r?r,r,r-�
percent_chaos��zCharsetMatch.percent_chaoscCr^r_)rcr:r?r,r,r-�percent_coherence�rezCharsetMatch.percent_coherencecCrH)z+
        Original untouched bytes.
        )r r?r,r,r-r>�szCharsetMatch.raw�list[CharsetMatch]cCrHrI)r&r?r,r,r-�submatch�rJzCharsetMatch.submatchcC�t|j�dkS�Nr)r;r&r?r,r,r-�has_submatch�szCharsetMatch.has_submatchcCs@|jdur|jSdd�t|�D�}ttdd�|D���|_|jS)NcSsg|]}t|��qSr,)r)rS�charr,r,r-rU�rVz*CharsetMatch.alphabets.<locals>.<listcomp>cSsh|]}|r|�qSr,r,)rS�rr,r,r-�	<setcomp>�rVz)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,)r3)rS�mr,r,r-rU�sz6CharsetMatch.could_be_from_charset.<locals>.<listcomp>)r!r&r?r,r,r-r\�sz"CharsetMatch.could_be_from_charset�utf_8r3cs~�jdus
�j|kr<|�_t��}�jdur5�j��dvr5tt�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�utf8rscs<|j|��d|��d��|��dt�j��dd��S)Nrr�_�-)�string�span�replace�groupsrr()rrr?r,r-�<lambda>�s
�z%CharsetMatch.output.<locals>.<lambda>i r)�country)r(rr*�lowerrr�encoder')r+r3�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.
        )rr��	hexdigestr?r,r,r-r4�szCharsetMatch.fingerprint)NN)rrrrrrrrrrrrrr)r/r0r1r)r1r�r1r)r/rr1rC)r1rK�r1r)r1r)r1rg)rs)r3rr1r)�__name__�
__module__�__qualname__r.r6r=�propertyr<rArBrGr3rOrQrRrr]r9r:rdrfr>rhrkrqr\r�r4r,r,r,r-r
sX�




	rc@sbeZdZdZdddd�Zd d	d
�Zd!dd�Zd"dd�Zd#dd�Zd$dd�Z	d%dd�Z
d%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.
    N�results�list[CharsetMatch] | NonecCs|r	t|�|_dSg|_dSrI)ro�_results)r+r�r,r,r-r.�szCharsetMatches.__init__r1�Iterator[CharsetMatch]ccs�|jEdHdSrI�r�r?r,r,r-�__iter__�s�zCharsetMatches.__iter__�item�	int | strrcCsJt|t�r
|j|St|t�r#t|d�}|jD]}||jvr"|Sqt�)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)r2�intr�rrr\�KeyError)r+r��resultr,r,r-�__getitem__s





�zCharsetMatches.__getitem__r�cCs
t|j�SrI�r;r�r?r,r,r-�__len__s
zCharsetMatches.__len__rcCrirjr�r?r,r,r-�__bool__szCharsetMatches.__bool__rCcCs|t|t�std�t|j����t|j�tkr0|j	D]}|j
|j
kr/|j|jkr/|�|�dSq|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)r2rr7rDrrEr;r>r
r�r4r9rGrFro)r+r��matchr,r,r-rFs
��

�zCharsetMatches.append�CharsetMatch | NonecCs|jsdS|jdS)zQ
        Simply return the first match. Strict equivalent to matches[0].
        Nrr�r?r,r,r-�best)s
zCharsetMatches.bestcCs|��S)zP
        Redundant method, call the method best(). Kept for BC reasons.
        )r�r?r,r,r-�first1szCharsetMatches.firstrI)r�r�)r1r�)r�r�r1r)r1r�r�)r�rr1rC)r1r�)r�r�r��__doc__r.r�r�r�r�rFr�r�r,r,r,r-r��s





r�c@s.eZdZddd�Zeddd��Zddd�ZdS)�CliDetectionResult�pathrr3rrOrK�alternative_encodingsr]rqrrr9rr:�unicode_path�is_preferredcCsF||_|
|_||_||_||_||_||_||_||_|	|_	||_
dSrI)r�r�r3rOr�r]rqrr9r:r�)r+r�r3rOr�r]rqrr9r:r�r�r,r,r-r.=s
zCliDetectionResult.__init__r1�dict[str, Any]cCs2|j|j|j|j|j|j|j|j|j|j	|j
d�S)N�r�r3rOr�r]rqrr9r:r�r�r�r?r,r,r-�__dict__Ws�zCliDetectionResult.__dict__cCst|jddd�S)NT�)�ensure_ascii�indent)rr�r?r,r,r-�to_jsongszCliDetectionResult.to_jsonN)r�rr3rrOrKr�rKr]rrqrKrrr9rr:rr�rr�r)r1r�r�)r�r�r�r.r�r�r�r,r,r,r-r�<s

r�N)�
__future__rZencodings.aliasesr�hashlibr�jsonr�rer�typingrrr	r
Zconstantrr
�utilsrrrrr�rrZCoherenceMatchrr�r,r,r,r-�<module>siC