ó
    ’•hj0  ã                  óÐ   • S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
JrJrJrJr  SSKJrJr  SS	KJrJrJr   " S
 S5      r " S S5      r\\\4   r\\   r " S S5      rg)é    )Úannotations)Úaliases)Úsha256)Údumps)Úsub)ÚAnyÚIteratorÚListÚTupleé   )ÚRE_POSSIBLE_ENCODING_INDICATIONÚTOO_BIG_SEQUENCE)Ú	iana_nameÚis_multi_byte_encodingÚunicode_rangec                  óÔ  • \ rS rSr  S             SS jjrSS jrSS jr\SS j5       rS S jr	S S jr
S!S	 jr\S S
 j5       r\S"S j5       r\S#S j5       r\S#S j5       r\S"S j5       r\S S j5       r\SS j5       r\SS j5       r\SS j5       r\SS j5       r\S$S j5       r\S%S j5       r\S#S j5       r\S"S j5       r\S"S j5       rS&S'S jjr\S S j5       rSrg)(ÚCharsetMatché   Nc                óž   • Xl         X l        X0l        XPl        X@l        S U l        / U l        SU l        S U l        S U l	        X`l
        Xpl        g )Nç        )Ú_payloadÚ	_encodingÚ_mean_mess_ratioÚ
_languagesÚ_has_sig_or_bomÚ_unicode_rangesÚ_leavesÚ_mean_coherence_ratioÚ_output_payloadÚ_output_encodingÚ_stringÚ_preemptive_declaration)ÚselfÚpayloadÚguessed_encodingÚmean_mess_ratioÚhas_sig_or_bomÚ	languagesÚdecoded_payloadÚpreemptive_declarations           Ú;/usr/lib/python3/dist-packages/charset_normalizer/models.pyÚ__init__ÚCharsetMatch.__init__   sQ   € ð  'Œà.ŒØ'6ÔØ,5ŒØ%3ÔØ15ˆÔà+-ˆŒØ,/ˆÔ"à-1ˆÔØ,0ˆÔà#2Œà3IÕ$ó    c                óú   • [        U[        5      (       d.  [        U[        5      (       a  [        U5      U R                  :H  $ gU R                  UR                  :H  =(       a    U R
                  UR
                  :H  $ )NF)Ú
isinstancer   Ústrr   ÚencodingÚfingerprint©r#   Úothers     r+   Ú__eq__ÚCharsetMatch.__eq__*   s\   € Ü˜%¤×.Ñ.Ü˜%¤×%Ñ%Ü  Ó'¨4¯=©=Ñ8Ð8ØØ�}‰} §¡Ñ.×X°4×3CÑ3CÀu×GXÑGXÑ3XÐXr.   c                óò  • [        U[        5      (       d  [        e[        U R                  UR                  -
  5      n[        U R
                  UR
                  -
  5      nUS:  a  US:”  a  U R
                  UR
                  :„  $ US:  aU  US::  aO  [        U R                  5      [        :¼  a  U R                  UR                  :  $ U R                  UR                  :„  $ U R                  UR                  :  $ )zA
Implemented to make sorted available upon CharsetMatches items.
g{®Gáz„?g{®Gáz”?)
r0   r   Ú
ValueErrorÚabsÚchaosÚ	coherenceÚlenr   r   Úmulti_byte_usage)r#   r5   Úchaos_differenceÚcoherence_differences       r+   Ú__lt__ÚCharsetMatch.__lt__1   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                ó\   • S[        [        U 5      5      [        U R                  5      -  -
  $ )Ng      ð?)r=   r1   Úraw©r#   s    r+   r>   ÚCharsetMatch.multi_byte_usageG   s"   € à”cœ#˜d›)“n¤s¨4¯8©8£}Ñ4Ñ5Ð5r.   c                ó€   • U R                   c&  [        U R                  U R                  S5      U l         U R                   $ )NÚstrict)r!   r1   r   r   rE   s    r+   Ú__str__ÚCharsetMatch.__str__K   s.   € à�<‰<ÑÜ˜tŸ}™}¨d¯n©n¸hÓGˆDŒLØ�|‰|Ðr.   c                ó<   • SU R                    SU R                   S3$ )Nz<CharsetMatch 'z' bytes(z)>)r2   r3   rE   s    r+   Ú__repr__ÚCharsetMatch.__repr__Q   s"   € Ø  §¡ ¨x¸×8HÑ8HÐ7IÈÐLÐLr.   c                óÄ   • [        U[        5      (       a  X:X  a$  [        SR                  UR                  5      5      eS Ul        U R                  R                  U5        g )Nz;Unable to add instance <{}> as a submatch of a CharsetMatch)r0   r   r9   ÚformatÚ	__class__r!   r   Úappendr4   s     r+   Úadd_submatchÚCharsetMatch.add_submatchT   sP   € Ü˜%¤×.Ñ.°%³-ÜØM×TÑTØ—O‘Oóóð ð ˆŒØ�‰×Ñ˜EÕ"r.   c                ó   • U R                   $ ©N)r   rE   s    r+   r2   ÚCharsetMatch.encoding_   s   € à�~‰~Ðr.   c                óÒ   • / n[         R                  " 5        HK  u  p#U R                  U:X  a  UR                  U5        M(  U R                  U:X  d  M:  UR                  U5        MM     U$ )zr
Encoding name are known by many name, using this could help when searching for IBM855 when it's listed as CP855.
)r   Úitemsr2   rQ   )r#   Úalso_known_asÚuÚps       r+   Úencoding_aliasesÚCharsetMatch.encoding_aliasesc   sW   € ð
 $&ˆÜ—M’M–O‰DˆAØ�}‰} Ó!Ø×$Ñ$ QÖ'Ø—‘ !Õ#Ø×$Ñ$ QÖ'ñ	 $ð
 Ðr.   c                ó   • U R                   $ rU   ©r   rE   s    r+   ÚbomÚCharsetMatch.bomp   ó   € à×#Ñ#Ð#r.   c                ó   • U R                   $ rU   r_   rE   s    r+   Úbyte_order_markÚCharsetMatch.byte_order_markt   rb   r.   c                óJ   • U R                    Vs/ s H  oS   PM	     sn$ s  snf )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(   ÚCharsetMatch.languagesx   s"   € ð #ŸošoÓ.šo˜�!”™oÑ.Ð.ùÒ.s   � c                ó,  • U R                   (       dr  SU R                  ;   a  gSSKJnJn  [        U R                  5      (       a  U" U R                  5      OU" U R                  5      n[        U5      S:X  d  SU;   a  gUS   $ U R                   S   S   $ )zz
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.cdrm   rn   r   r2   r=   )r#   rm   rn   r(   s       r+   ÚlanguageÚCharsetMatch.language€   sŠ   € ð ��ð ˜$×4Ñ4Ó4Ø ÷ Xô *¨$¯-©-×8Ñ8ñ & d§m¡mÔ4á'¨¯©Ó6ð ô �9‹~ Ó" m°yÓ&@Ø à˜Q‘<Ðà�‰˜qÑ! !Ñ$Ð$r.   c                ó   • U R                   $ rU   )r   rE   s    r+   r;   ÚCharsetMatch.chaosœ   s   € à×$Ñ$Ð$r.   c                óJ   • U R                   (       d  gU R                   S   S   $ )Nr   r   r   rg   rE   s    r+   r<   ÚCharsetMatch.coherence    s    € à��ØØ�‰˜qÑ! !Ñ$Ð$r.   c                ó0   • [        U R                  S-  SS9$ ©Néd   é   )Úndigits)Úroundr;   rE   s    r+   Úpercent_chaosÚCharsetMatch.percent_chaos¦   s   € ä�T—Z‘Z #Ñ%¨qÑ1Ð1r.   c                ó0   • [        U R                  S-  SS9$ ry   )r}   r<   rE   s    r+   Úpercent_coherenceÚCharsetMatch.percent_coherenceª   s   € ä�T—^‘^ cÑ)°1Ñ5Ð5r.   c                ó   • U R                   $ )z
Original untouched bytes.
)r   rE   s    r+   rD   ÚCharsetMatch.raw®   s   € ð
 �}‰}Ðr.   c                ó   • U R                   $ rU   )r   rE   s    r+   ÚsubmatchÚCharsetMatch.submatchµ   s   € à�|‰|Ðr.   c                ó2   • [        U R                  5      S:„  $ ©Nr   )r=   r   rE   s    r+   Úhas_submatchÚCharsetMatch.has_submatch¹   s   € ä�4—<‘<Ó  1Ñ$Ð$r.   c                ó  • U R                   b  U R                   $ [        U 5       Vs/ s H  n[        U5      PM     nn[        [	        U Vs1 s H  o3(       d  M  UiM     sn5      5      U l         U R                   $ s  snf s  snf rU   )r   r1   r   ÚsortedÚlist)r#   ÚcharÚdetected_rangesÚrs       r+   Ú	alphabetsÚCharsetMatch.alphabets½   sp   € à×ÑÑ+Ø×'Ñ'Ð'äMPÐQUÌYÓ,WÊYÀT¬]¸4Ö-@ÉYˆÐ,Wä%¤d±Ó+L²°!Ë!¯A±Ñ+LÓ&MÓNˆÔØ×#Ñ#Ð#ùò -Xùâ+Ls   §A<Á
BÁBc                ót   • U R                   /U R                   Vs/ s H  oR                  PM     sn-   $ s  snf )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   r2   )r#   Úms     r+   rp   Ú"CharsetMatch.could_be_from_charsetÇ   s.   € ð —‘Ð°t·|²|Ó"D²|°!§:¤:±|Ñ"DÑDÐDùÒ"Ds   ›5c                ó:  ^ • T R                   b  T R                   U:w  ar  UT l         [        T 5      nT R                  b<  T R                  R                  5       S;  a  [	        [
        U 4S jUSS SS9nX2SS -   nUR                  US5      T l        T R                  $ )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)zutf-8Úutf8Úutf_8c                óî   >• U R                   U R                  5       S   U R                  5       S    R                  U R                  5       S   [	        TR
                  5      R                  SS5      5      $ )Nr   r   Ú_Ú-)ÚstringÚspanÚreplaceÚgroupsr   r    )r•   r#   s    €r+   Ú<lambda>Ú%CharsetMatch.output.<locals>.<lambda>ß   sW   ø€ ˜aŸh™h q§v¡v£x°¡{°Q·V±V³X¸a±[ÐA×IÑIØŸ™›
 1™Ü! $×"7Ñ"7Ó8×@Ñ@ÀÀcÓJôr.   i    r   )ÚcountrŸ   )r    r1   r"   Úlowerr   r   Úencoder   )r#   r2   Údecoded_stringÚpatched_headers   `   r+   ÚoutputÚCharsetMatch.outputÐ   sª   ø€ ð
 × Ñ Ñ(¨D×,AÑ,AÀXÓ,MØ$,ˆDÔ!Ü  ›YˆNà×,Ñ,Ñ8Ø×0Ñ0×6Ñ6Ó8Ø1ó2ô "%Ü3ôð # 5 DÐ)Øñ"�ð "0ÀÀÐ2GÑ!G�à#1×#8Ñ#8¸À9Ó#MˆDÔ à×#Ñ#Ð#r.   c                óP   • [        U R                  5       5      R                  5       $ )zg
Retrieve the unique SHA256 computed using the transformed (re-encoded) payload. Not the original one.
)r   r¨   Ú	hexdigestrE   s    r+   r3   ÚCharsetMatch.fingerprintí   s   € ô
 �d—k‘k“mÓ$×.Ñ.Ó0Ð0r.   )r   r   r   r   r   r   r    r   r   r"   r!   r   )NN)r$   Úbytesr%   r1   r&   Úfloatr'   Úboolr(   ÚCoherenceMatchesr)   ú
str | Noner*   r±   )r5   ÚobjectÚreturnr¯   )r³   r®   ©r³   r1   )r5   r   r³   ÚNone)r³   ú	list[str]©r³   r¯   )r³   r­   )r³   zlist[CharsetMatch])r™   )r2   r1   r³   r­   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r,   r6   rA   Úpropertyr>   rI   rL   rR   r2   r\   r`   rd   r(   rr   r;   r<   r~   r�   rD   r†   rŠ   r’   rp   r¨   r3   Ú__static_attributes__© r.   r+   r   r      sÑ  † ð '+Ø-1ðJàðJð ðJð ð	Jð
 ðJð $ðJð $ðJð !+õJô8Yô(ð, ó6ó ð6ôôMô	#ð óó ðð ó
ó ð
ð ó$ó ð$ð ó$ó ð$ð ó/ó ð/ð ó%ó ð%ð6 ó%ó ð%ð ó%ó ð%ð
 ó2ó ð2ð ó6ó ð6ð óó ðð óó ðð ó%ó ð%ð ó$ó ð$ð óEó ðEö$ð: ó1ó ó1r.   r   c                  ól   • \ rS rSrSrSSS jjrSS jrSS jrSS jrSS jr	SS	 jr
SS
 jrSS jrSrg)ÚCharsetMatcheséõ   z§
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.
Nc                óB   • U(       a  [        U5      U l        g / U l        g rU   )r�   Ú_results)r#   Úresultss     r+   r,   ÚCharsetMatches.__init__û   s   € Þ?F¬F°7«Oˆ�ÈBˆ�r.   c              #  ó8   #   • U R                    S h  v•N   g  N7frU   ©rÃ   rE   s    r+   Ú__iter__ÚCharsetMatches.__iter__þ   s   é € Ø—=‘=× Ó ùs   ‚’“c                óä   • [        U[        5      (       a  U R                  U   $ [        U[        5      (       a2  [	        US5      nU R                   H  nXR
                  ;   d  M  Us  $    [        e)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)r0   ÚintrÃ   r1   r   rp   ÚKeyError)r#   ÚitemÚresults      r+   Ú__getitem__ÚCharsetMatches.__getitem__  s_   € ô
 �dœC× Ñ Ø—=‘= Ñ&Ð&Ü�dœC× Ñ Ü˜T 5Ó)ˆDØŸ-œ-�Ø×7Ñ7Õ7Ø!’Mñ (ô ˆr.   c                ó,   • [        U R                  5      $ rU   ©r=   rÃ   rE   s    r+   Ú__len__ÚCharsetMatches.__len__  s   € Ü�4—=‘=Ó!Ð!r.   c                ó2   • [        U R                  5      S:„  $ r‰   rÒ   rE   s    r+   Ú__bool__ÚCharsetMatches.__bool__  s   € Ü�4—=‘=Ó! AÑ%Ð%r.   c                óä  • [        U[        5      (       d-  [        SR                  [	        UR
                  5      5      5      e[        UR                  5      [        :  a\  U R                   HL  nUR                  UR                  :X  d  M  UR                  UR                  :X  d  M;  UR                  U5          g   U R                  R                  U5        [        U R                  5      U l	        g)zf
Insert a single match. Will be inserted accordingly to preserve sort.
Can be inserted as a submatch.
z-Cannot append instance '{}' to CharsetMatchesN)r0   r   r9   rO   r1   rP   r=   rD   r   rÃ   r3   r;   rR   rQ   r�   )r#   rÍ   Úmatchs      r+   rQ   ÚCharsetMatches.append  s±   € ô
 ˜$¤×-Ñ-ÜØ?×FÑFÜ˜Ÿ™Ó'óóð ô ˆt�x‰x‹=Ô+Ó+ØŸœ�Ø×$Ñ$¨×(8Ñ(8Õ8¸U¿[¹[ÈDÏJÉJÕ=VØ×&Ñ& tÔ,Ùñ 'ð 	�‰×Ñ˜TÔ"Ü˜tŸ}™}Ó-ˆ�r.   c                óD   • U R                   (       d  gU R                   S   $ )zA
Simply return the first match. Strict equivalent to matches[0].
Nr   rÇ   rE   s    r+   ÚbestÚCharsetMatches.best)  s   € ð �}�}ØØ�}‰}˜QÑÐr.   c                ó"   • U R                  5       $ )z@
Redundant method, call the method best(). Kept for BC reasons.
)rÜ   rE   s    r+   ÚfirstÚCharsetMatches.first1  s   € ð �y‰y‹{Ðr.   rÇ   rU   )rÄ   zlist[CharsetMatch] | None)r³   zIterator[CharsetMatch])rÍ   z	int | strr³   r   )r³   rË   r·   )rÍ   r   r³   rµ   )r³   zCharsetMatch | None)r¸   r¹   rº   r»   Ú__doc__r,   rÈ   rÏ   rÓ   rÖ   rQ   rÜ   rß   r½   r¾   r.   r+   rÀ   rÀ   õ   s0   † ñö
Oô!ôô"ô&ô.ô( ÷r.   rÀ   c                  óh   • \ rS rSr                      SS jr\SS j5       rS	S jrSrg)
ÚCliDetectionResulti<  c                óˆ   • Xl         X l        X l        X0l        X@l        XPl        X`l        Xpl        X€l        X�l	        X°l
        g rU   )ÚpathÚunicode_pathr2   r\   Úalternative_encodingsrr   r’   r'   r;   r<   Úis_preferred)r#   rå   r2   r\   rç   rr   r’   r'   r;   r<   ræ   rè   s               r+   r,   ÚCliDetectionResult.__init__=  s@   € ð Œ	Ø(4ÔØ$,ŒØ+;ÔØ0EÔ"Ø%ŒØ$-ŒØ$2ÔØ!Œ
Ø )ŒØ".Õr.   c                óú   • U R                   U R                  U R                  U R                  U R                  U R
                  U R                  U R                  U R                  U R                  U R                  S.$ )N©rå   r2   r\   rç   rr   r’   r'   r;   r<   ræ   rè   rë   rE   s    r+   Ú__dict__ÚCliDetectionResult.__dict__W  se   € ð —I‘IØŸ™Ø $× 5Ñ 5Ø%)×%?Ñ%?ØŸ™ØŸ™Ø"×1Ñ1Ø—Z‘ZØŸ™Ø ×-Ñ-Ø ×-Ñ-ñ
ð 	
r.   c                ó,   • [        U R                  SSS9$ )NTé   )Úensure_asciiÚindent)r   rì   rE   s    r+   Úto_jsonÚCliDetectionResult.to_jsong  s   € Ü�T—]‘]°¸aÑ@Ð@r.   )r’   rç   r;   r<   r2   r\   r'   rè   rr   rå   ræ   N)rå   r1   r2   r±   r\   r¶   rç   r¶   rr   r1   r’   r¶   r'   r¯   r;   r®   r<   r®   ræ   r±   rè   r¯   )r³   zdict[str, Any]r´   )	r¸   r¹   rº   r»   r,   r¼   rì   rò   r½   r¾   r.   r+   rã   rã   <  s�   † ð/àð/ð ð/ð $ð	/ð
  )ð/ð ð/ð ð/ð ð/ð ð/ð ð/ð !ð/ð ô/ð4 ó
ó ð
÷Ar.   rã   N)Ú
__future__r   Úencodings.aliasesr   Úhashlibr   Újsonr   Úrer   Útypingr   r	   r
   r   Úconstantr   r   Úutilsr   r   r   r   rÀ   r1   r®   ÚCoherenceMatchr°   rã   r¾   r.   r+   Ú<module>rý      sd   ðÝ "å %Ý Ý Ý ß -Ó -ç Gß CÑ C÷e1ñ e1÷P@ñ @ðF �s˜E�zÑ"€Ø˜Ñ'Ð ÷,Aò ,Ar.   