Ë
    G<k25  ã                  ó¸   — 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
 ddlmZ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)é    )Úannotations)Úaliases)Úsub)ÚAnyÚIteratorÚListÚTupleé   )ÚRE_POSSIBLE_ENCODING_INDICATIONÚTOO_BIG_SEQUENCE)Ú	iana_nameÚis_multi_byte_encodingÚunicode_rangec                  ó˜  — e Zd Z	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zdd„Zdd„Zedd„«       Zdd„Zdd„Z	dd„Z
edd	„«       Zed d
„«       Zed!d„«       Zed!d„«       Zed d„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zed"d„«       Zed#d„«       Zed!d„«       Zed d„«       Zed d„«       Zd$d%d„Zed&d„«       Zy)'ÚCharsetMatchNc                ó¬   — || _         || _        || _        || _        || _        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Ú_preemptive_declaration)ÚselfÚpayloadÚguessed_encodingÚmean_mess_ratioÚhas_sig_or_bomÚ	languagesÚdecoded_payloadÚpreemptive_declarations           ú\/var/www/tapir-food/flask_app/venv/lib/python3.12/site-packages/charset_normalizer/models.pyÚ__init__zCharsetMatch.__init__   s_   € ð ,3ˆŒà.ˆŒØ'6ˆÔØ,5ˆŒØ%3ˆÔØ15ˆÔà+-ˆŒØ,/ˆÔ"à-1ˆÔØ,0ˆÔà#2ˆŒà3IˆÕ$ó    c                óÞ   — t        |t        «      s*t        |t        «      rt        |d«      | j                  k(  S y| j                  |j                  k(  xr | j
                  |j
                  k(  S )NF)Ú
isinstancer   Ústrr   ÚencodingÚfingerprint©r    Úothers     r(   Ú__eq__zCharsetMatch.__eq__(   sZ   € Ü˜%¤Ô.Ü˜%¤Ô%ô
 ! ¨Ó.°$·-±-Ñ?Ð?ØØ�}‰} §¡Ñ.Ò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ázt?g{®Gáz”?)
r,   r   Ú
ValueErrorÚabsÚchaosÚ	coherenceÚlenr   r   Úmulti_byte_usage)r    r1   Úchaos_differenceÚcoherence_differences       r(   Ú__lt__zCharsetMatch.__lt__3   sÊ   € ô ˜%¤Ô.ÜÐä"% d§j¡j°5·;±;Ñ&>Ó"?ÐÜ&)¨$¯.©.¸5¿?¹?Ñ*JÓ&KÐð ˜eÒ#Ð(<¸tÒ(CØ—>‘> E§O¡OÑ3Ð3Ø Ò%Ð*>À$Ò*Fô �4—=‘=Ó!Ô%5Ò5Ø—z‘z E§K¡KÑ/Ð/Ø×(Ñ(¨5×+AÑ+AÑAÐAà�z‰z˜EŸK™KÑ'Ð'r*   c                ól   — t        | j                  «      }|dk(  rydt        t        | «      «      |z  z
  S )Nr   r   g      ð?)r8   Úrawr-   )r    Úraw_lens     r(   r9   zCharsetMatch.multi_byte_usageI   s3   € ô �d—h‘h“-ˆØ�aŠ<ØØ”cœ#˜d›)“n wÑ.Ñ/Ð/r*   c                ó  — | j                   €rt        | j                  | j                  d«      | _         | j                  r@| j                  dv r2| j                   r&| j                   d   dk(  r| j                   dd  | _         | j                   S )NÚstrict>   Úutf_7Úgb18030r   u   ï»¿r
   )r   r-   r   r   r   ©r    s    r(   Ú__str__zCharsetMatch.__str__Q   so   € à�<‰<ÐÜ˜tŸ}™}¨d¯n©n¸hÓGˆDŒLð ×$Ò$Ø—N‘NÐ&:Ñ:Ø—L’LØ—L‘L ‘O xÒ/à#Ÿ|™|¨A¨BÐ/�”Ø�|‰|Ðr*   c                ó<   — d| j                   › d| j                  › d�S )Nz<CharsetMatch 'z' fp(z)>)r.   r/   rD   s    r(   Ú__repr__zCharsetMatch.__repr__b   s"   € Ø  §¡ ¨u°T×5EÑ5EÐ4FÀbÐIÐIr*   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   r4   ÚformatÚ	__class__r   r   Úappendr0   s     r(   Úadd_submatchzCharsetMatch.add_submatche   sO   € Ü˜%¤Ô.°%¸4²-ÜØM×TÑTØ—O‘Oóóð ð ˆŒØ�‰×Ñ˜EÕ"r*   c                ó   — | j                   S ©N)r   rD   s    r(   r.   zCharsetMatch.encodingp   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   Úitemsr.   rK   )r    Úalso_known_asÚuÚps       r(   Úencoding_aliaseszCharsetMatch.encoding_aliasest   s^   € ð
 $&ˆÜ—M‘M“Oò 	(‰DˆAˆqØ�}‰} Ò!Ø×$Ñ$ QÕ'Ø—‘ !Ó#Ø×$Ñ$ QÕ'ð		(ð
 Ðr*   c                ó   — | j                   S rN   ©r   rD   s    r(   ÚbomzCharsetMatch.bom�   ó   € à×#Ñ#Ð#r*   c                ó   — | j                   S rN   rV   rD   s    r(   Úbyte_order_markzCharsetMatch.byte_order_mark…   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.languages‰   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   r.   r8   )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(   r6   zCharsetMatch.chaos­   s   € à×$Ñ$Ð$r*   c                ó@   — | j                   sy| j                   d   d   S )Nr   r   r
   r\   rD   s    r(   r7   zCharsetMatch.coherence±   s    € à�ŠØØ�‰˜qÑ! !Ñ$Ð$r*   c                ó6   — t        | j                  dz  d¬«      S ©Néd   é   )Úndigits)Úroundr6   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   r7   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(   r>   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   )r8   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   r-   r   ÚsortedÚlist)r    ÚcharÚdetected_rangesÚrs       r(   Ú	alphabetszCharsetMatch.alphabetsÎ   sk   € à×ÑÐ+Ø×'Ñ'Ð'äMPÐQUËYÖ,WÀT¬]¸4Õ-@Ð,WˆÐ,Wä%¤d°Ö+L°!Ê!ªAÒ+LÓ&MÓNˆÔØ×#Ñ#Ð#ùò -Xùâ+Ls   ¦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   r.   )r    Úms     r(   rd   z"CharsetMatch.could_be_from_charsetØ   s,   € ð —‘Ð°t·|±|Ö"D°! 1§:£:Ò"DÑDÐDùÒ"Ds   ›3c                óR  ‡— | j                   �| j                   ‰k7  r€t        | «      }| j                  �K| j                  j                  «       dvst	        ‰d«      dvr!t        t        ˆfd„|dd d¬«      }||dd z   }|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.
        N)zutf-8Úutf8Úutf_8F)rƒ   Ú	utf_8_sigc                óÚ   •— | j                   | j                  «       d   | j                  «       d    j                  | j                  «       d   t	        ‰«      j                  dd«      «      S )Nr   r
   Ú_ú-)ÚstringÚspanÚreplaceÚgroupsr   )r€   r.   s    €r(   ú<lambda>z%CharsetMatch.output.<locals>.<lambda>î   sS   ø€ ˜aŸh™h q§v¡v£x°¡{°Q·V±V³X¸a±[ÐA×IÑIØŸ™›
 1™Ü! (Ó+×3Ñ3°C¸Ó=ó€ r*   i    r
   )ÚcountrŠ   )	r   r-   r   Úlowerr   r   r   Úencoder   )r    r.   Údecoded_stringÚpatched_headers    `  r(   ÚoutputzCharsetMatch.outputá   s¸   ø€ ð
 × Ñ Ð(¨D×,AÑ,AÀXÒ,MÜ  ›YˆNØ×+Ñ+Ð7Ø×,Ñ,×2Ñ2Ó4Ð<VÑVÜ˜X uÓ-Ð5KÑKä!$Ü3óð # 5 DÐ)Øô"�ð "0°.ÀÀÐ2GÑ!G�à#1×#8Ñ#8¸À9Ó#MˆDÔ Ø$,ˆDÔ!à×#Ñ#Ð#r*   c                ó*   — t        t        | «      «      S )z]
        Retrieve a hash fingerprint of the decoded payload, used for deduplication.
        )Úhashr-   rD   s    r(   r/   zCharsetMatch.fingerprintý   s   € ô
 ”C˜“I‹Ðr*   )NN)r!   úbytes | bytearrayr"   r-   r#   Úfloatr$   Úboolr%   ÚCoherenceMatchesr&   ú
str | Noner'   r™   )r1   ÚobjectÚreturnr—   )r›   r–   ©r›   r-   )r1   r   r›   ÚNone)r›   ú	list[str]©r›   r—   )r›   r•   )r›   zlist[CharsetMatch])rƒ   )r.   r-   r›   Úbytes©r›   Úint)Ú__name__Ú
__module__Ú__qualname__r)   r2   r<   Úpropertyr9   rE   rG   rL   r.   rT   rW   rZ   r%   rf   r6   r7   ro   rq   r>   rt   rw   r~   rd   r’   r/   © r*   r(   r   r      sÑ  „ ð '+Ø-1ðJà"ðJð ðJð ð	Jð
 ðJð $ðJð $ðJð !+óJó8	Yó(ð, ò0ó ð0óó"Jó	#ð òó ðð ò
ó ð
ð ò$ó ð$ð ò$ó ð$ð ò/ó ð/ð ò%ó ð%ð6 ò%ó ð%ð ò%ó ð%ð
 ò2ó ð2ð ò6ó ð6ð òó ðð òó ðð ò%ó ð%ð ò$ó ð$ð òEó ðEô$ð8 òó ñr*   r   c                  óZ   — e Zd ZdZddd„Zdd„Zdd„Zdd„Zdd„Zdd„Z	dd	„Z
dd
„Zd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.
    Nc                ó:   — |rt        |«      ng | _        d| _        y ©NT)ry   Ú_resultsÚ
_is_sorted)r    Úresultss     r(   r)   zCharsetMatches.__init__  s   € Ù?F¬F°7¬OÈBˆŒØ $ˆ�r*   c                ó`   — | j                   s"| j                  j                  «        d| _         y y r«   )r­   r¬   ÚsortrD   s    r(   Ú_ensure_sortedzCharsetMatches._ensure_sorted  s%   € Ø�ŠØ�M‰M×ÑÔ Ø"ˆD�Oð r*   c              #  óX   K  — | j                  «        | j                  E d {  –—†  y 7 Œ­wrN   )r±   r¬   rD   s    r(   Ú__iter__zCharsetMatches.__iter__  s   è ø€ Ø×ÑÔØ—=‘=× Ò ús   ‚ *¢(£*c                óê   — t        |t        «      r| j                  «        | 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,   r¢   r±   r¬   r-   r   rd   ÚKeyError)r    ÚitemÚresults      r(   Ú__getitem__zCharsetMatches.__getitem__  sl   € ô
 �dœCÔ Ø×ÑÔ!Ø—=‘= Ñ&Ð&Ü�dœCÔ Ü˜T 5Ó)ˆDØŸ-™-ò "�Ø˜6×7Ñ7Ò7Ø!’Mð"ô ˆr*   c                ó,   — t        | j                  «      S rN   ©r8   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                  |«       d| _        y)z~
        Insert a single match. Will be inserted accordingly to preserve sort.
        Can be inserted as a submatch.
        z-Cannot append instance '{}' to CharsetMatchesNF)r,   r   r4   rI   r-   rJ   r8   r>   r   r¬   r/   r6   rL   rK   r­   )r    r¶   Úmatchs      r(   rK   zCharsetMatches.append-  sª   € ô
 ˜$¤Ô-ÜØ?×FÑFÜ˜Ÿ™Ó'óóð ô ˆt�x‰x‹=Ô+Ò+ØŸ™ò �Ø×$Ñ$¨×(8Ñ(8Ó8¸U¿[¹[ÈDÏJÉJÓ=VØ×&Ñ& tÔ,Ùðð 	�‰×Ñ˜TÔ"Øˆ�r*   c                óZ   — | j                   sy| j                  «        | j                   d   S )zQ
        Simply return the first match. Strict equivalent to matches[0].
        Nr   )r¬   r±   rD   s    r(   ÚbestzCharsetMatches.bestA  s)   € ð �}Š}ØØ×ÑÔØ�}‰}˜QÑÐr*   c                ó"   — | j                  «       S )zP
        Redundant method, call the method best(). Kept for BC reasons.
        )rÁ   rD   s    r(   ÚfirstzCharsetMatches.firstJ  s   € ð �y‰y‹{Ðr*   rN   )r®   zlist[CharsetMatch] | None)r›   r�   )r›   zIterator[CharsetMatch])r¶   z	int | strr›   r   r¡   rŸ   )r¶   r   r›   r�   )r›   zCharsetMatch | None)r£   r¤   r¥   Ú__doc__r)   r±   r³   r¸   r»   r½   rK   rÁ   rÃ   r§   r*   r(   r©   r©     s4   „ ñô
%ó#ó
!óó"ó&ó ó( ôr*   r©   c                  óZ   — e Zd Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zedd„«       Zdd„Zy)ÚCliDetectionResultc                óž   — || _         |
| _        || _        || _        || _        || _        || _        || _        || _        |	| _	        || _
        y rN   )ÚpathÚunicode_pathr.   rT   Úalternative_encodingsrf   r~   r$   r6   r7   Úis_preferred)r    rÈ   r.   rT   rÊ   rf   r~   r$   r6   r7   rÉ   rË   s               r(   r)   zCliDetectionResult.__init__V  sV   € ð ˆŒ	Ø(4ˆÔØ$,ˆŒØ+;ˆÔØ0EˆÔ"Ø%ˆŒØ$-ˆŒØ$2ˆÔØ!ˆŒ
Ø )ˆŒØ".ˆÕr*   c                óú   — | j                   | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  dœS )N©rÈ   r.   rT   rÊ   rf   r~   r$   r6   r7   rÉ   rË   rÍ   rD   s    r(   Ú__dict__zCliDetectionResult.__dict__p  se   € ð —I‘IØŸ™Ø $× 5Ñ 5Ø%)×%?Ñ%?ØŸ™ØŸ™Ø"×1Ñ1Ø—Z‘ZØŸ™Ø ×-Ñ-Ø ×-Ñ-ñ
ð 	
r*   c                ó8   — ddl m}  || j                  dd¬«      S )Nr   )ÚdumpsTé   )Úensure_asciiÚindent)ÚjsonrÐ   rÎ   )r    rÐ   s     r(   Úto_jsonzCliDetectionResult.to_json€  s   € Ýá�T—]‘]°¸aÔ@Ð@r*   N)rÈ   r-   r.   r™   rT   rž   rÊ   rž   rf   r-   r~   rž   r$   r—   r6   r–   r7   r–   rÉ   r™   rË   r—   )r›   zdict[str, Any]rœ   )r£   r¤   r¥   r)   r¦   rÎ   rÕ   r§   r*   r(   rÆ   rÆ   U  s�   „ ð/àð/ð ð/ð $ð	/ð
  )ð/ð ð/ð ð/ð ð/ð ð/ð ð/ð !ð/ð ó/ð4 ò
ó ð
ôAr*   rÆ   N)Ú
__future__r   Úencodings.aliasesr   Úrer   Útypingr   r   r   r	   Úconstantr   r   Úutilsr   r   r   r   r©   r-   r–   ÚCoherenceMatchr˜   rÆ   r§   r*   r(   ú<module>rÝ      s^   ðÝ "å %Ý ß -Ó -ç Gß CÑ C÷wñ w÷tIñ IðX �s˜E�zÑ"€Ø˜Ñ'Ð ÷.Aò .Ar*   