HEX
Server: Apache
System: Linux sh-pro142.hostgator.com.br 5.14.0-162.23.1.9991722448259.nf.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 31 18:11:45 UTC 2024 x86_64
User: okform09 (1324)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: //usr/libexec/oracle-cloud-agent/plugins/osms/charset_normalizer/models.pyc
a

ٓ�fh-�@s�ddlmZddlmZddlmZddlmZmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZmZmZGdd	�d	�ZGd
d�d�ZeeefZe
eZGdd
�d
�ZdS)�)�aliases)�sha256)�dumps)�Any�Dict�Iterator�List�Optional�Tuple�Union�)�TOO_BIG_SEQUENCE)�	iana_name�is_multi_byte_encoding�
unicode_rangec@s�eZdZd8eeeedeed�dd�Ze	ed�dd�Z
e	ed�d	d
�Zeed�dd
��Z
ed�dd�Zed�dd�Zddd�dd�Zeed�dd��Zeeed�dd��Zeed�dd��Zeed�dd��Zeeed�dd��Zeed�dd��Zeed�d d!��Zeed�d"d#��Zeed�d$d%��Zeed�d&d'��Zeed�d(d)��Zeedd�d*d+��Zeed�d,d-��Zeeed�d.d/��Zeeed�d0d1��Z d9eed3�d4d5�Z!eed�d6d7��Z"dS):�CharsetMatchN�CoherenceMatches)�payload�guessed_encoding�mean_mess_ratio�has_sig_or_bom�	languages�decoded_payloadcCsF||_||_||_||_||_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)�selfrrrrrr�r&�}/sparta/input/_build_configuration/image_build+validate/lib/bmcenv/lib64/python3.9/site-packages/charset_normalizer/models.py�__init__s	zCharsetMatch.__init__)�other�returncCs>t|t�s&td�t|j�t|j����|j|jko<|j|jkS)Nz&__eq__ cannot be invoked on {} and {}.)�
isinstancer�	TypeError�format�str�	__class__�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�?)
r+r�
ValueError�abs�chaos�	coherence�lenrr
�multi_byte_usage)r%r)�chaos_difference�coherence_differencer&r&r'�__lt__-s
zCharsetMatch.__lt__�r*cCsdtt|��t|j�S)Ng�?)r8r.�raw�r%r&r&r'r9CszCharsetMatch.multi_byte_usagecCs"|jdurt|j|jd�|_|jS)N�strict)r$r.rrr?r&r&r'�__str__Gs
zCharsetMatch.__str__cCsd�|j|j�S)Nz<CharsetMatch '{}' bytes({})>)r-r0r1r?r&r&r'�__repr__MszCharsetMatch.__repr__cCs8t|t�r||kr"td�|j���d|_|j�|�dS)Nz;Unable to add instance <{}> as a submatch of a CharsetMatch)r+rr4r-r/r$r �appendr2r&r&r'�add_submatchPs��zCharsetMatch.add_submatchcCs|jS�N)rr?r&r&r'r0[szCharsetMatch.encodingcCsDg}t��D]2\}}|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�itemsr0rC)r%�
also_known_as�u�pr&r&r'�encoding_aliases_s

zCharsetMatch.encoding_aliasescCs|jSrE�rr?r&r&r'�bomlszCharsetMatch.bomcCs|jSrErKr?r&r&r'�byte_order_markpszCharsetMatch.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�z*CharsetMatch.languages.<locals>.<listcomp>�rr?r&r&r'rtszCharsetMatch.languagescCsp|jsbd|jvrdSddlm}m}t|j�r8||j�n||j�}t|�dksVd|vrZdS|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.cdrUrVrr0r8)r%rUrVrr&r&r'�language|s
��zCharsetMatch.languagecCs|jSrE)rr?r&r&r'r6�szCharsetMatch.chaoscCs|js
dS|jddS)NrrrrRr?r&r&r'r7�szCharsetMatch.coherencecCst|jddd�S�N�d�)�ndigits)�roundr6r?r&r&r'�
percent_chaos�szCharsetMatch.percent_chaoscCst|jddd�Sr[)r_r7r?r&r&r'�percent_coherence�szCharsetMatch.percent_coherencecCs|jS)z+
        Original untouched bytes.
        )rr?r&r&r'r>�szCharsetMatch.rawcCs|jSrE)r r?r&r&r'�submatch�szCharsetMatch.submatchcCst|j�dkS�Nr)r8r r?r&r&r'�has_submatch�szCharsetMatch.has_submatchcCs@|jdur|jSdd�t|�D�}ttdd�|D���|_|jS)NcSsg|]}t|��qSr&)r)rN�charr&r&r'rP�sz*CharsetMatch.alphabets.<locals>.<listcomp>cSsh|]}|r|�qSr&r&)rN�rr&r&r'�	<setcomp>�rQz)CharsetMatch.alphabets.<locals>.<setcomp>)rr.�sorted�list)r%�detected_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&)r0)rN�mr&r&r'rP�rQz6CharsetMatch.could_be_from_charset.<locals>.<listcomp>)rr r?r&r&r'rX�sz"CharsetMatch.could_be_from_charset�utf_8)r0r*cCs2|jdus|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#r.�encoder")r%r0r&r&r'�output�szCharsetMatch.outputcCst|�����S)zw
        Retrieve the unique SHA256 computed using the transformed (re-encoded) payload. Not the original one.
        )rrp�	hexdigestr?r&r&r'r1�szCharsetMatch.fingerprint)N)rm)#�__name__�
__module__�__qualname__�bytesr.�float�boolr	r(�objectr3r<�propertyr9rArBrDr0rrJrLrMrrZr6r7r`rar>rbrdrkrXrpr1r&r&r&r'r
sb��	rc@s�eZdZdZdeeed�dd�Zeed�dd�Z	e
eefed	�d
d�Z
ed�dd
�Zed�dd�Zedd	�dd�Zedd�dd�Zedd�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)�resultscCs|rt|�ng|_dSrE)rh�_results)r%r{r&r&r'r(�szCharsetMatches.__init__r=ccs|jEdHdSrE�r|r?r&r&r'�__iter__�szCharsetMatches.__iter__)�itemr*cCsNt|t�r|j|St|t�rFt|d�}|jD]}||jvr.|Sq.t�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)r+�intr|r.rrX�KeyError)r%r�resultr&r&r'�__getitem__�s






zCharsetMatches.__getitem__cCs
t|j�SrE�r8r|r?r&r&r'�__len__�szCharsetMatches.__len__cCst|j�dkSrcr�r?r&r&r'�__bool__�szCharsetMatches.__bool__cCs|t|t�std�t|j����t|j�tkr`|j	D],}|j
|j
kr2|j|jkr2|�|�dSq2|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+rr4r-r.r/r8r>r
r|r1r6rDrCrh)r%r�matchr&r&r'rCs
��

zCharsetMatches.appendrcCs|js
dS|jdS)zQ
        Simply return the first match. Strict equivalent to matches[0].
        Nrr}r?r&r&r'�bestszCharsetMatches.bestcCs|��S)zP
        Redundant method, call the method best(). Kept for BC reasons.
        )r�r?r&r&r'�firstszCharsetMatches.first)N)rrrsrt�__doc__r	rrr(rr~rr�r.r�r�rwr�rCr�r�r&r&r&r'rz�srzc@sjeZdZeeeeeeeeeeeeeeeed�dd�Ze	e
eefd�dd��Zed�dd�Z
d	S)
�CliDetectionResult��pathr0rJ�alternative_encodingsrZrkrr6r7�unicode_path�is_preferredcCsF||_|
|_||_||_||_||_||_||_||_|	|_	||_
dSrE)r�r�r0rJr�rZrkrr6r7r�)r%r�r0rJr�rZrkrr6r7r�r�r&r&r'r()szCliDetectionResult.__init__r=cCs2|j|j|j|j|j|j|j|j|j|j	|j
d�S)Nr�r�r?r&r&r'�__dict__Cs�zCliDetectionResult.__dict__cCst|jddd�S)NT�)�ensure_ascii�indent)rr�r?r&r&r'�to_jsonSszCliDetectionResult.to_jsonN)rrrsrtr.r	rrwrvr(ryrrr�r�r&r&r&r'r�(s�r�N)�encodings.aliasesr�hashlibr�jsonr�typingrrrrr	r
r�constantr
�utilsrrrrrzr.rv�CoherenceMatchrr�r&r&r&r'�<module>s$XC