Ë
    £2Úih-  ã                   óÀ   — d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	m
Z
mZmZmZ ddlmZ ddlmZmZmZ  G d„ d	«      Z G d
„ d«      Zeeef   Ze
e   Z G d„ d«      Zy)é    )Úaliases)Úsha256)Údumps)ÚAnyÚDictÚIteratorÚListÚOptionalÚTupleÚUnioné   )ÚTOO_BIG_SEQUENCE)Ú	iana_nameÚis_multi_byte_encodingÚunicode_rangec                   ó  — e Zd Z	 d$dededededddee   fd	„Zd
e	defd„Z
d
e	defd„Zedefd„«       Zdefd„Zdefd„Zd%d„Zedefd„«       Zedee   fd„«       Zedefd„«       Zedefd„«       Zedee   fd„«       Zedefd„«       Zedefd„«       Zedefd„«       Zedefd„«       Zedefd„«       Zedefd„«       Zeded    fd„«       Zedefd„«       Zedee   fd„«       Zedee   fd „«       Z d&d!edefd"„Z!edefd#„«       Z"y)'ÚCharsetMatchNÚpayloadÚguessed_encodingÚmean_mess_ratioÚhas_sig_or_bomÚ	languagesÚCoherenceMatchesÚdecoded_payloadc                 óž   — || _         || _        || _        || _        || _        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)Úselfr   r   r   r   r   r   s          úP/var/www/html/acx/venv/lib/python3.12/site-packages/charset_normalizer/models.pyÚ__init__zCharsetMatch.__init__   sW   € ð  'ˆŒà.ˆŒØ'6ˆÔØ,5ˆŒØ%3ˆÔØ48ˆÔà+-ˆŒØ,/ˆÔ"à04ˆÔØ/3ˆÔà&5ˆ�ó    ÚotherÚreturnc                 ó  — t        |t        «      sAt        dj                  t	        |j
                  «      t	        | j
                  «      «      «      ‚| j                  |j                  k(  xr | j                  |j                  k(  S )Nz&__eq__ cannot be invoked on {} and {}.)Ú
isinstancer   Ú	TypeErrorÚformatÚstrÚ	__class__ÚencodingÚfingerprint©r(   r,   s     r)   Ú__eq__zCharsetMatch.__eq__$   si   € Ü˜%¤Ô.ÜØ8×?Ñ?Ü˜Ÿ™Ó(¬#¨d¯n©nÓ*=óóð ð
 �}‰} §¡Ñ.ÒX°4×3CÑ3CÀu×GXÑGXÑ3XÐXr+   c                 óÞ  — t        |t        «      st        ‚t        | j                  |j                  z
  «      }t        | j
                  |j
                  z
  «      }|dk  r|dkD  r| j
                  |j
                  kD  S |dk  rS|dk  rNt        | j                  «      t        k\  r| j                  |j                  k  S | j                  |j                  kD  S | j                  |j                  k  S )zQ
        Implemented to make sorted available upon CharsetMatches items.
        g{®Gáz„?g{®Gáz”?)
r/   r   Ú
ValueErrorÚabsÚchaosÚ	coherenceÚlenr   r   Úmulti_byte_usage)r(   r,   Úchaos_differenceÚcoherence_differences       r)   Ú__lt__zCharsetMatch.__lt__-   sÊ   € ô ˜%¤Ô.ÜÐä"% 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                 ó\   — dt        t        | «      «      t        | j                  «      z  z
  S )Ng      ð?)r=   r2   Úraw©r(   s    r)   r>   zCharsetMatch.multi_byte_usageC   s"   € à”cœ#˜d›)“n¤s¨4¯8©8£}Ñ4Ñ5Ð5r+   c                 ó~   — | j                   €&t        | j                  | j                  d«      | _         | j                   S )NÚstrict)r'   r2   r   r   rD   s    r)   Ú__str__zCharsetMatch.__str__G   s.   € à�<‰<ÐÜ˜tŸ}™}¨d¯n©n¸hÓGˆDŒLØ�|‰|Ðr+   c                 óN   — dj                  | j                  | j                  «      S )Nz<CharsetMatch '{}' bytes({})>)r1   r4   r5   rD   s    r)   Ú__repr__zCharsetMatch.__repr__M   s   € Ø.×5Ñ5°d·m±mÀT×EUÑEUÓVÐVr+   c                 óº   — t        |t        «      r|| k(  r$t        dj                  |j                  «      «      ‚d |_        | j                  j                  |«       y )Nz;Unable to add instance <{}> as a submatch of a CharsetMatch)r/   r   r9   r1   r3   r'   r#   Úappendr6   s     r)   Úadd_submatchzCharsetMatch.add_submatchP   sO   € Ü˜%¤Ô.°%¸4²-ÜØM×TÑTØ—O‘Oóóð ð ˆŒØ�‰×Ñ˜EÕ"r+   c                 ó   — | j                   S ©N)r   rD   s    r)   r4   zCharsetMatch.encoding[   s   € à�~‰~Ðr+   c                 óÆ   — g }t        j                  «       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   Úitemsr4   rK   )r(   Úalso_known_asÚuÚps       r)   Úencoding_aliaseszCharsetMatch.encoding_aliases_   s^   € ð
 $&ˆÜ—M‘M“Oò 	(‰DˆAˆqØ�}‰} Ò!Ø×$Ñ$ QÕ'Ø—‘ !Ó#Ø×$Ñ$ QÕ'ð		(ð
 Ðr+   c                 ó   — | j                   S rN   ©r!   rD   s    r)   ÚbomzCharsetMatch.boml   ó   € à×#Ñ#Ð#r+   c                 ó   — | j                   S rN   rV   rD   s    r)   Úbyte_order_markzCharsetMatch.byte_order_markp   rX   r+   c                 óF   — | j                   D �cg c]  }|d   ‘Œ	 c}S c c}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   zCharsetMatch.languagest   s    € ð #Ÿo™oÖ.˜��!“Ò.Ð.ùÒ.s   �c                 ó  — | j                   shd| j                  v ryddlm}m} t        | j                  «      r || j                  «      n || j                  «      }t        |«      dk(  sd|v ry|d   S | j                   d   d   S )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_languageszLatin BasedÚUnknown)r    Úcould_be_from_charsetÚcharset_normalizer.cdra   rb   r   r4   r=   )r(   ra   rb   r   s       r)   ÚlanguagezCharsetMatch.language|   s‡   € ð �Šð ˜$×4Ñ4Ñ4Ø ÷ Xô *¨$¯-©-Ô8ñ & d§m¡mÔ4á'¨¯©Ó6ð ô �9‹~ Ò" m°yÑ&@Ø à˜Q‘<Ðà�‰˜qÑ! !Ñ$Ð$r+   c                 ó   — | j                   S rN   )r   rD   s    r)   r;   zCharsetMatch.chaos˜   s   € à×$Ñ$Ð$r+   c                 ó@   — | j                   sy| j                   d   d   S )Nr   r   r   r\   rD   s    r)   r<   zCharsetMatch.coherenceœ   s    € à�ŠØØ�‰˜qÑ! !Ñ$Ð$r+   c                 ó6   — t        | j                  dz  d¬«      S ©Néd   é   )Úndigits)Úroundr;   rD   s    r)   Úpercent_chaoszCharsetMatch.percent_chaos¢   s   € ä�T—Z‘Z #Ñ%¨qÔ1Ð1r+   c                 ó6   — t        | j                  dz  d¬«      S rj   )rn   r<   rD   s    r)   Úpercent_coherencezCharsetMatch.percent_coherence¦   s   € ä�T—^‘^ cÑ)°1Ô5Ð5r+   c                 ó   — | j                   S )z+
        Original untouched bytes.
        )r   rD   s    r)   rC   zCharsetMatch.rawª   s   € ð
 �}‰}Ðr+   c                 ó   — | j                   S rN   )r#   rD   s    r)   ÚsubmatchzCharsetMatch.submatch±   s   € à�|‰|Ðr+   c                 ó2   — t        | j                  «      dkD  S ©Nr   )r=   r#   rD   s    r)   Úhas_submatchzCharsetMatch.has_submatchµ   s   € ä�4—<‘<Ó  1Ñ$Ð$r+   c                 óô   — | j                   �| j                   S t        | «      D �cg c]  }t        |«      ‘Œ }}t        t	        |D �ch c]  }|sŒ|’Œ	 c}«      «      | _         | j                   S c c}w c c}w rN   )r"   r2   r   ÚsortedÚlist)r(   ÚcharÚdetected_rangesÚrs       r)   Ú	alphabetszCharsetMatch.alphabets¹   sw   € à×ÑÐ+Ø×'Ñ'Ð'ô -0°«Iö0
Ø$(ŒM˜$Õð0
ˆð 0
ô  &¤d°Ö+L°!Ê!ªAÒ+LÓ&MÓNˆÔØ×#Ñ#Ð#ùò0
ùò ,Ms   ¦A0ÁA5ÁA5c                 óp   — | j                   g| j                  D �cg c]  }|j                  ‘Œ c}z   S c c}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'.
        )r   r#   r4   )r(   Úms     r)   rd   z"CharsetMatch.could_be_from_charsetÅ   s,   € ð —‘Ð°t·|±|Ö"D°! 1§:£:Ò"DÑDÐDùÒ"Ds   ›3r4   c                 óž   — | j                   �| j                   |k7  r'|| _         t        | «      j                  |d«      | _        | j                  S )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.
        Úreplace)r&   r2   Úencoder%   )r(   r4   s     r)   ÚoutputzCharsetMatch.outputÎ   sJ   € ð
 × Ñ Ð(¨D×,AÑ,AÀXÒ,MØ$,ˆDÔ!Ü#& t£9×#3Ñ#3°H¸iÓ#HˆDÔ à×#Ñ#Ð#r+   c                 óP   — t        | j                  «       «      j                  «       S )zw
        Retrieve the unique SHA256 computed using the transformed (re-encoded) payload. Not the original one.
        )r   r„   Ú	hexdigestrD   s    r)   r5   zCharsetMatch.fingerprintÙ   s   € ô
 �d—k‘k“mÓ$×.Ñ.Ó0Ð0r+   rN   )r,   r   r-   N)Úutf_8)#Ú__name__Ú
__module__Ú__qualname__Úbytesr2   ÚfloatÚboolr
   r*   Úobjectr7   rA   Úpropertyr>   rG   rI   rL   r4   r	   rT   rW   rZ   r   rf   r;   r<   ro   rq   rC   rt   rw   r~   rd   r„   r5   © r+   r)   r   r   
   sˆ  „ ð *.ñ6àð6ð ð6ð ð	6ð
 ð6ð &ð6ð " #™ó6ð2Y˜Fð Y tó Yð(˜Fð ( tó (ð, ð6 %ò 6ó ð6ð˜ó ðW˜#ó Wó	#ð ð˜#ò ó ðð ð
 $ s¡)ò 
ó ð
ð ð$�Tò $ó ð$ð ð$ ò $ó ð$ð ð/˜4 ™9ò /ó ð/ð ð%˜#ò %ó ð%ð6 ð%�uò %ó ð%ð ð%˜5ò %ó ð%ð
 ð2˜uò 2ó ð2ð ð6 5ò 6ó ð6ð ð�Uò ó ðð ð˜$˜~Ñ.ò ó ðð ð%˜dò %ó ð%ð ð	$˜4 ™9ò 	$ó ð	$ð ðE t¨C¡yò Eó ðEñ	$˜sð 	$°ó 	$ð ð1˜Sò 1ó ñ1r+   r   c                   ó¢   — e Zd ZdZddeee      fd„Zdee   fd„Z	de
eef   defd„Zdefd	„Zdefd
„Zdeddfd„Zded   fd„Zded   fd„Zy)Ú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Úresultsc                 ó8   — |rt        |«      | _        y g | _        y rN   )ry   Ú_results)r(   r“   s     r)   r*   zCharsetMatches.__init__ç   s   € Ù?F¬F°7«Oˆ�ÈBˆ�r+   r-   c              #   ó8   K  — | j                   E d {  –—†  y 7 Œ­wrN   ©r•   rD   s    r)   Ú__iter__zCharsetMatches.__iter__ê   s   è ø€ Ø—=‘=× Ò ús   ‚’“Úitemc                 óÊ   — t        |t        «      r| j                  |   S t        |t        «      r/t	        |d«      }| j                  D ]  }||j
                  v sŒ|c S  t        ‚)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•   r2   r   rd   ÚKeyError)r(   r™   Úresults      r)   Ú__getitem__zCharsetMatches.__getitem__í   s`   € ô
 �dœCÔ Ø—=‘= Ñ&Ð&Ü�dœCÔ Ü˜T 5Ó)ˆDØŸ-™-ò "�Ø˜6×7Ñ7Ò7Ø!’Mð"ô ˆr+   c                 ó,   — t        | j                  «      S rN   ©r=   r•   rD   s    r)   Ú__len__zCharsetMatches.__len__û   s   € Ü�4—=‘=Ó!Ð!r+   c                 ó2   — t        | j                  «      dkD  S rv   r    rD   s    r)   Ú__bool__zCharsetMatches.__bool__þ   s   € Ü�4—=‘=Ó! AÑ%Ð%r+   c                 óÎ  — t        |t        «      s-t        dj                  t	        |j
                  «      «      «      ‚t        |j                  «      t        k  rW| j                  D ]H  }|j                  |j                  k(  sŒ|j                  |j                  k(  sŒ7|j                  |«        y | j                  j                  |«       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/   r   r9   r1   r2   r3   r=   rC   r   r•   r5   r;   rL   rK   ry   )r(   r™   Úmatchs      r)   rK   zCharsetMatches.append  s³   € ô
 ˜$¤Ô-ÜØ?×FÑFÜ˜Ÿ™Ó'óóð ô ˆt�x‰x‹=Ô,Ò,ØŸ™ò �Ø×$Ñ$¨×(8Ñ(8Ó8¸U¿[¹[ÈDÏJÉJÓ=VØ×&Ñ& tÔ,Ùðð 	�‰×Ñ˜TÔ"Ü˜tŸ}™}Ó-ˆ�r+   r   c                 ó:   — | j                   sy| j                   d   S )zQ
        Simply return the first match. Strict equivalent to matches[0].
        Nr   r—   rD   s    r)   ÚbestzCharsetMatches.best  s   € ð �}Š}ØØ�}‰}˜QÑÐr+   c                 ó"   — | j                  «       S )zP
        Redundant method, call the method best(). Kept for BC reasons.
        )r§   rD   s    r)   ÚfirstzCharsetMatches.first  s   € ð �y‰y‹{Ðr+   rN   )rˆ   r‰   rŠ   Ú__doc__r
   r	   r   r*   r   r˜   r   r›   r2   rž   r¡   r�   r£   rK   r§   r©   r�   r+   r)   r’   r’   á   s˜   „ ññ
O ¨¨lÑ);Ñ <ó Oð!˜( <Ñ0ó !ð  c¨3 h¡ð °Ló ð"˜ó "ð&˜$ó &ð.˜<ð .¨Dó .ð( �h˜~Ñ.ó  ð�x Ñ/ô r+   r’   c                   óŠ   — e Zd Zdedee   dee   dee   dedee   deded	ed
ee   defd„Ze	de
eef   fd„«       Zdefd„Zy)ÚCliDetectionResultÚpathr4   rT   Úalternative_encodingsrf   r~   r   r;   r<   Úunicode_pathÚis_preferredc                 óž   — || _         |
| _        || _        || _        || _        || _        || _        || _        || _        |	| _	        || _
        y rN   )r­   r¯   r4   rT   r®   rf   r~   r   r;   r<   r°   )r(   r­   r4   rT   r®   rf   r~   r   r;   r<   r¯   r°   s               r)   r*   zCliDetectionResult.__init__)  sV   € ð ˆŒ	Ø+7ˆÔØ'/ˆŒØ+;ˆÔØ0EˆÔ"Ø%ˆŒØ$-ˆŒØ$2ˆÔØ!ˆŒ
Ø )ˆŒØ".ˆÕr+   r-   c                 óú   — | j                   | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  dœS )N©r­   r4   rT   r®   rf   r~   r   r;   r<   r¯   r°   r³   rD   s    r)   Ú__dict__zCliDetectionResult.__dict__C  se   € ð —I‘IØŸ™Ø $× 5Ñ 5Ø%)×%?Ñ%?ØŸ™ØŸ™Ø"×1Ñ1Ø—Z‘ZØŸ™Ø ×-Ñ-Ø ×-Ñ-ñ
ð 	
r+   c                 ó2   — t        | j                  dd¬«      S )NTé   )Úensure_asciiÚindent)r   r´   rD   s    r)   Úto_jsonzCliDetectionResult.to_jsonS  s   € Ü�T—]‘]°¸aÔ@Ð@r+   N)rˆ   r‰   rŠ   r2   r
   r	   r�   rŒ   r*   r�   r   r   r´   r¹   r�   r+   r)   r¬   r¬   (  s¸   „ ð/àð/ð ˜3‘-ð/ð ˜s™)ð	/ð
  $ C™yð/ð ð/ð ˜‘9ð/ð ð/ð ð/ð ð/ð ˜s‘mð/ð ó/ð4 ð
˜$˜s C˜x™.ò 
ó ð
ðA˜ô Ar+   r¬   N)Úencodings.aliasesr   Úhashlibr   Újsonr   Útypingr   r   r   r	   r
   r   r   Úconstantr   Úutilsr   r   r   r   r’   r2   rŒ   ÚCoherenceMatchr   r¬   r�   r+   r)   ú<module>rÁ      sa   ðÝ %Ý Ý ß D× DÑ Då &ß CÑ C÷T1ñ T1÷n@ñ @ðF �s˜E�zÑ"€Ø˜Ñ'Ð ÷,Aò ,Ar+   