§
    ¥	Êj0  ã                  óà   — d dl mZ d dlZd dlZd dlZd dlmZmZmZm	Z	m
Z
 d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ ddd„Z G d„ d¦  «        Zddd„Zedk    r e¦   «          dS dS )é    )ÚannotationsN)ÚabspathÚbasenameÚdirnameÚjoinÚrealpath)Úpython_version)Úunidata_version)Úfrom_fp)ÚCliDetectionResult)Ú__version__ÚyesÚquestionÚstrÚdefaultÚreturnÚboolc                óÌ   — |dk    rdnd}	 t          | |z   ¦  «                             ¦   «                              ¦   «         }|s|dk    S |dv rdS |dv rdS t          d¦  «         ŒZ)	zBAsk a yes/no question via input() and return the answer as a bool.r   z [Y/n] z [y/N] T)Úyr   )ÚnÚnoFzPlease respond with 'y' or 'n'.)ÚinputÚstripÚlowerÚprint)r   r   ÚpromptÚchoices       úOC:\Projects\Muse2API\.venv\Lib\site-packages\charset_normalizer/cli/__main__.pyÚquery_yes_nor      s‹   € à! UÒ*Ð*ˆYˆY°	€Fð1Ý�x &Ñ(Ñ)Ô)×/Ò/Ñ1Ô1×7Ò7Ñ9Ô9ˆØð 	$Ø˜eÒ#Ð#Ø�\Ð!Ð!Ø�4Ø�[Ð Ð Ø�5ÝÐ/Ñ0Ô0Ð0ð1ó    c                  ó4   — e Zd ZdZ	 	 	 	 ddd„Zdd„Zdd„ZdS )ÚFileTypeaè  Factory for creating file object types

    Instances of FileType are typically passed as type= arguments to the
    ArgumentParser add_argument() method.

    Keyword Arguments:
        - mode -- A string indicating how the file is to be opened. Accepts the
            same values as the builtin open() function.
        - bufsize -- The file's desired buffer size. Accepts the same values as
            the builtin open() function.
        - encoding -- The file's encoding. Accepts the same values as the
            builtin open() function.
        - errors -- A string indicating how encoding and decoding errors are to
            be handled. Accepts the same value as the builtin open() function.

    Backported from CPython 3.12
    ÚréÿÿÿÿNÚmoder   ÚbufsizeÚintÚencodingú
str | NoneÚerrorsc                ó>   — || _         || _        || _        || _        d S ©N)Ú_modeÚ_bufsizeÚ	_encodingÚ_errors)Úselfr%   r&   r(   r*   s        r   Ú__init__zFileType.__init__2   s$   € ð ˆŒ
ØˆŒØ!ˆŒØˆŒˆˆr    Ústringr   ú	typing.IOc                óÎ  ‡ — |dk    r‰d‰ j         v r&d‰ j         v rt          j        j        nt          j        S t	          ˆ fd„dD ¦   «         ¦  «        r&d‰ j         v rt          j        j        nt          j        S d‰ j         › �}t          |¦  «        ‚	 t          |‰ j         ‰ j        ‰ j	        ‰ j
        ¦  «        S # t          $ r!}d|› d|› �}t          j        |¦  «        ‚d }~ww xY w)	Nú-r#   Úbc              3  ó*   •K  — | ]}|‰j         v V — Œd S r,   )r-   )Ú.0Úcr1   s     €r   ú	<genexpr>z$FileType.__call__.<locals>.<genexpr>C   s)   øè è € Ð4Ð4¨�Q˜$œ*�_Ð4Ð4Ð4Ð4Ð4Ð4r    Úwaxzargument "-" with mode zcan't open 'z': )r-   ÚsysÚstdinÚbufferÚanyÚstdoutÚ
ValueErrorÚopenr.   r/   r0   ÚOSErrorÚargparseÚArgumentTypeError)r1   r3   ÚmsgÚeÚmessages   `    r   Ú__call__zFileType.__call__>   sý   ø€ à�SŠ=ˆ=Ø�d”jÐ Ð Ø+.°$´*Ð+<Ð+<•s”yÔ'Ð'Å#Ä)ÐKÝÐ4Ð4Ð4Ð4¨eÐ4Ñ4Ô4Ñ4Ô4ð &Ø,/°4´:Ð,=Ð,=•s”zÔ(Ð(Å3Ä:ÐMà<°´
Ð<Ð<�Ý  ‘o”oÐ%ð	6Ý˜ ¤
¨D¬M¸4¼>È4Ì<ÑXÔXÐXøÝð 	6ð 	6ð 	6Ø3 VÐ3Ð3°Ð3Ð3ˆGÝÔ,¨WÑ5Ô5Ð5øøøøð	6øøøs   Â&B9 Â9
C$ÃCÃC$c                óÎ   — | j         | j        f}d| j        fd| j        fg}d                     d„ |D ¦   «         d„ |D ¦   «         z   ¦  «        }t          | ¦  «        j        › d|› d�S )Nr(   r*   ú, c                ó8   — g | ]}|d k    ¯t          |¦  «        ‘ŒS )r$   )Úrepr)r9   Úargs     r   ú
<listcomp>z%FileType.__repr__.<locals>.<listcomp>T   s#   € Ð4Ð4Ð4˜3¨#°ª)¨)�T�#‰YŒY¨)¨)¨)r    c                ó&   — g | ]\  }}|®|› d|›�‘ŒS )Nú=© )r9   ÚkwrO   s      r   rP   z%FileType.__repr__.<locals>.<listcomp>U   s'   € ÐHÐHÐH¡7 2 s¸¸�"ˆˆ�sˆˆ¸¸¸r    ú(ú))r-   r.   r/   r0   r   ÚtypeÚ__name__)r1   ÚargsÚkwargsÚargs_strs       r   Ú__repr__zFileType.__repr__P   s…   € ØŒz˜4œ=Ð(ˆØ˜tœ~Ð.°¸4¼<Ð0HÐIˆØ—9’9Ø4Ð4 $Ð4Ñ4Ô4ØHÐH¨fÐHÑHÔHñIñ
ô 
ˆõ �t‘*”*Ô%Ð3Ð3¨Ð3Ð3Ð3Ð3r    )r#   r$   NN)r%   r   r&   r'   r(   r)   r*   r)   )r3   r   r   r4   )r   r   )rX   Ú
__module__Ú__qualname__Ú__doc__r2   rJ   r\   rS   r    r   r"   r"      sm   € € € € € ðð ð( ØØ#Ø!ð
ð 
ð 
ð 
ð 
ð6ð 6ð 6ð 6ð$4ð 4ð 4ð 4ð 4ð 4r    r"   Úargvúlist[str] | Noner'   c                óÒ  ‡‡‡— t          j        d¬¦  «        }|                     dt          d¦  «        dd¬¦  «         |                     dd	d
ddd¬¦  «         |                     ddd
ddd¬¦  «         |                     ddd
ddd¬¦  «         |                     ddd
ddd¬¦  «         |                     ddd
ddd¬¦  «         |                     dd d
dd!d"¬¦  «         |                     d#d$d
dd%d&¬¦  «         |                     d'd(d)d*t          d+d,¬-¦  «         |                     d.d/d0                     t          t          ¦   «         t          t          j
                             ¦   «                              d1¦  «        rd2nd3¦  «        d4¬5¦  «         |                     | ¦  «        }|j        d6u rK|j        du rB|j        r|j        D ]Š‰                     ¦   «          Œt%          d7t&          j        ¬8¦  «         d9S |j        d6u rK|j        du rB|j        r|j        D ]Š‰                     ¦   «          Œt%          d:t&          j        ¬8¦  «         d9S |j        d;k     s|j        d<k    rB|j        r|j        D ]Š‰                     ¦   «          Œt%          d=t&          j        ¬8¦  «         d9S g }|j        D �]%Št/          ‰|j        |j        |j        du ¬>¦  «        }|                     ¦   «         Š‰€�t%          d@                     ‰j        |j        d<k     rdAndB¦  «        t&          j        ¬8¦  «         |                     t;          t=          ‰j        ¦  «        d?g g dCg dd<d;d?d6¦  «        ¦  «         �nJt;          t=          ‰j        ¦  «        ‰j        ‰j         ˆfdD„‰j!        D ¦   «         ‰j"        ‰j#        ‰j$        ‰j%        ‰j&        d?d6¦  «        }|                     |¦  «         tO          |¦  «        d9k    r„|j(        r}|D ]zŠ‰‰k    rr|                     t;          t=          ‰j        ¦  «        ‰j        ‰j         ˆfdE„‰j!        D ¦   «         ‰j"        ‰j#        ‰j$        ‰j%        ‰j&        d?d¦  «        ¦  «         Œ{|j        d6u �r5‰j         )                    dF¦  «        d6u rRt%          dG                     ‰j        ¦  «        t&          j        ¬8¦  «         ‰j*        du r‰                     ¦   «          �ŒAtW          tY          ‰j        ¦  «        ¦  «        }t[          tY          ‰j        ¦  «        ¦  «        }| .                    dH¦  «        }|j        du r9| /                    dI‰j        ¦  «         ‰j*        du r‰                     ¦   «          nR|j        du rIta          dJ                     ‰j        ¦  «        dK¦  «        du r‰j*        du r‰                     ¦   «          �Œ,	 tc          |dH 1                    |¦  «        ¦  «        |_2        tg          |j2        dL¦  «        5 }	|	 4                    ‰ 5                    ¦   «         ¦  «         d?d?d?¦  «         n# 1 swxY w Y   n^# tl          $ rQ}
t%          to          |
¦  «        t&          j        ¬8¦  «         ‰j*        du r‰                     ¦   «          Y d?}
~
 dMS d?}
~
ww xY w‰j*        du r‰                     ¦   «          �Œ'|j8        du rLdNdOl9m:} t%           |tO          |¦  «        d9k    rdP„ |D ¦   «         n|dN         j;        d6dQ¬R¦  «        ¦  «         n8|j        D ]0Št%          dS 1                    ˆfdT„|D ¦   «         ¦  «        ¦  «         Œ1dNS )Uzˆ
    CLI assistant using ARGV and ArgumentParser
    :param argv:
    :return: 0 if everything is fine, anything else equal trouble
    zvThe Real First Universal Charset Detector. Discover originating encoding used on text file. Normalize text to unicode.)ÚdescriptionÚfilesÚrbú+zFile(s) to be analysed)rW   ÚnargsÚhelpz-vz	--verboseÚ
store_trueFÚverbosezjDisplay complementary information about file if any. Stdout will contain logs about the detection process.)Úactionr   Údestrh   z-az--with-alternativeÚalternativeszIOutput complementary possibilities if any. Top-level JSON WILL be a list.z-nz--normalizeÚ	normalizezLPermit to normalize input file. If not set, program does not write anything.z-mz	--minimalÚminimalzBOnly output the charset detected to STDOUT. Disabling JSON output.z-rz	--replaceÚreplacezGReplace file when trying to normalize it instead of creating a new one.z-fz--forceÚforcezHReplace file without asking if you are sure, use this flag with caution.z-iz--no-preemptiveÚno_preemptivez>Disable looking at a charset declaration to hint the detector.z-tz--thresholdÚstoregš™™™™™É?Ú	thresholdzUDefine a custom maximum amount of noise allowed in decoded content. 0. <= noise <= 1.)rk   r   rW   rl   rh   z	--versionÚversionz;Charset-Normalizer {} - Python {} - Unicode {} - SpeedUp {}z.pyÚOFFÚONz"Show version information and exit.)rk   ru   rh   Tz.Use --replace in addition of --normalize only.)Úfileé   z*Use --force in addition of --replace only.g        g      ð?z---threshold VALUE should be between 0. AND 1.)rt   ÚexplainÚpreemptive_behaviourNz4Unable to identify originating encoding for "{}". {}z-Maybe try increasing maximum amount of chaos.Ú ÚUnknownc                ó*   •— g | ]}|‰j         k    ¯|‘ŒS rS   ©r(   )r9   ÚcpÚ
best_guesss     €r   rP   zcli_detect.<locals>.<listcomp>ú   s1   ø€ ð ð ð àØ˜ZÔ0Ò0Ð0ð à0Ð0Ð0r    c                ó*   •— g | ]}|‰j         k    ¯|‘ŒS rS   r   )r9   r€   Úels     €r   rP   zcli_detect.<locals>.<listcomp>  s0   ø€ ð !"ð !"ð !"à(*Ø')¨R¬[Ò'8Ð'8ð %'à'8Ð'8Ð'8r    ÚutfzJ"{}" file does not need to be normalized, as it already came from unicode.ú.r$   z0Are you sure to normalize "{}" by replacing it ?r   Úwbé   r   )Údumpsc                ó   — g | ]	}|j         ‘Œ
S rS   )Ú__dict__)r9   rƒ   s     r   rP   zcli_detect.<locals>.<listcomp>V  s   € Ð*Ð*Ð* �”Ð*Ð*Ð*r    é   )Úensure_asciiÚindentrL   c                ó\   •— g | ](}|j         t          ‰j        ¦  «        k    ¯|j        pd ‘Œ)S )Ú	undefined)Úpathr   Únamer(   )r9   rƒ   Úmy_files     €r   rP   zcli_detect.<locals>.<listcomp>_  sA   ø€ ð ð ð àØœ7¥g¨g¬lÑ&;Ô&;Ò;Ð;ð œÐ2 {à;Ð;Ð;r    )<rE   ÚArgumentParserÚadd_argumentr"   ÚfloatÚformatr   r	   r
   Ú	md_moduleÚ__file__r   ÚendswithÚ
parse_argsrp   rn   rd   Úcloser   r=   Ústderrrq   rt   r   rj   rr   Úbestr‘   Úappendr   r   r(   Úencoding_aliasesÚcould_be_from_charsetÚlanguageÚ	alphabetsÚbomÚpercent_chaosÚpercent_coherenceÚlenrm   Ú
startswithÚclosedr   r   r   ÚsplitÚinsertr   r   Úunicode_pathrC   ÚwriteÚoutputrD   r   ro   Újsonrˆ   rŠ   )r`   ÚparserrY   Úx_ÚmatchesÚ
cli_resultÚdir_pathÚ	file_nameÚo_ÚfprH   rˆ   r�   rƒ   r’   s               @@@r   Ú
cli_detectr·   Z   s5	  øøø€ õ Ô$ð%ðñ ô €Fð ×ÒØ•h˜t‘n”n¨CÐ6Nð ñ ô ð ð ×ÒØØØØØð@ð ñ ô ð ð ×ÒØØØØØØXð ñ ô ð ð ×ÒØØØØØØ[ð ñ ô ð ð ×ÒØØØØØØQð ñ ô ð ð ×ÒØØØØØØVð ñ ô ð ð ×ÒØØØØØØWð ñ ô ð ð ×ÒØØØØØØMð ñ ô ð ð ×ÒØØØØÝØØdð ñ ô ð ð ×ÒØØØM×TÒTÝÝÑÔÝÝÔ'×-Ò-Ñ/Ô/×8Ò8¸Ñ?Ô?ÐIˆEˆEÀTñ	
ô 
ð 2ð ñ 
ô 
ð 
ð ×Ò˜TÑ"Ô"€Dà„|�tÐÐ ¤°%Ð 7Ð 7ØŒ:ð 	 Øœ:ð  ð  �Ø—’‘”��ÝÐ>ÅSÄZÐPÑPÔPÐPØˆqà„z�TÐÐ˜dœl¨eÐ3Ð3ØŒ:ð 	 Øœ:ð  ð  �Ø—’‘”��ÝÐ:ÅÄÐLÑLÔLÐLØˆqà„~˜ÒÐ˜tœ~°Ò3Ð3ØŒ:ð 	 Øœ:ð  ð  �Ø—’‘”��ÝÐ=ÅCÄJÐOÑOÔOÐOØˆqà	€Bà”:ð ñ ˆÝØØ”nØ”LØ!%Ô!3°uÐ!<ð	
ñ 
ô 
ˆð —\’\‘^”^ˆ
àÐÝØF×MÒMØ”Lð  œ>¨CÒ/Ð/ð HÐGàñô õ ”Zð
ñ 
ô 
ð 
ð �IŠIÝ"Ý˜GœLÑ)Ô)ØØØØØØØØØØñô ñô ð ñ õ  ,Ý˜œÑ%Ô%ØÔ#ØÔ+ðð ð ð à(Ô>ðñ ô ð
 Ô#ØÔ$Ø”ØÔ(ØÔ,ØØñô ˆJð" �IŠI�jÑ!Ô!Ð!å�7‰|Œ|˜aÒÐ DÔ$5ÐØ!ð ð �BØ˜ZÒ'Ð'ØŸ	š	Ý.Ý '¨¬Ñ 5Ô 5Ø "¤Ø "Ô 3ð!"ð !"ð !"ð !"à.0Ô.Fð!"ñ !"ô !"ð
 !#¤Ø "¤Ø "¤Ø "Ô 0Ø "Ô 4Ø $Ø %ñô ñô ð øð( Œ~ Ð%Ñ%ØÔ&×1Ò1°%Ñ8Ô8¸DÐ@Ð@ÝØd×kÒkØ#œLñô õ !œZð	ñ ô ð ð ”~¨Ð.Ð.ØŸš™œ˜Ùå"¥8¨G¬LÑ#9Ô#9Ñ:Ô:�Ý$¥X¨g¬lÑ%;Ô%;Ñ<Ô<�	à )§¢°Ñ 4Ô 4�à”< 5Ð(Ð(Ø—I’I˜b *Ô"5Ñ6Ô6Ð6Ø”~¨Ð.Ð.ØŸš™œ˜øà”J %Ð'Ð'Ý$ØJ×QÒQØ#œLñô ð ñ	ô ð ðð ð ”~¨Ð.Ð.ØŸš™œ˜Ùð	Ý.2°8¸S¿XºXÀb¹\¼\Ñ.JÔ.J�JÔ+å˜jÔ5°tÑ<Ô<ð 6ÀØŸš ×!2Ò!2Ñ!4Ô!4Ñ5Ô5Ð5ð6ð 6ð 6ñ 6ô 6ð 6ð 6ð 6ð 6ð 6ð 6øøøð 6ð 6ð 6ð 6øøåð ð ð Ý�#˜a™&œ&¥s¤zÐ2Ñ2Ô2Ð2Ø”~¨Ð.Ð.ØŸš™œ˜Ø˜1˜1˜1˜1˜1˜1øøøøð	øøøð Œ>˜UÐ"Ð"Ø�MŠM‰OŒOˆOùà„|�uÐÐØÐÐÐÐÐåØˆEÝ.1°"©g¬g¸ªk¨kÐ*Ð* rÐ*Ñ*Ô*Ð*¸rÀ!¼u¼~Ø!Øðñ ô ñ	
ô 	
ð 	
ð 	
ð ”zð 		ð 		ˆGÝØ—	’	ðð ð ð à"$ðñ ô ñô ñô ð ð ð ˆ1s=   × =YØ(YÙYÙY	ÙYÙY	ÙYÙ
Z8Ù'AZ3Ú3Z8Ú__main__)r   )r   r   r   r   r   r   r,   )r`   ra   r   r'   )Ú
__future__r   rE   r=   ÚtypingÚos.pathr   r   r   r   r   Úplatformr	   Úunicodedatar
   Úcharset_normalizer.mdÚmdr—   Úcharset_normalizerr   Úcharset_normalizer.modelsr   Úcharset_normalizer.versionr   r   r"   r·   rX   rS   r    r   ú<module>rÃ      sM  ðØ "Ð "Ð "Ð "Ð "Ð "à €€€Ø 
€
€
€
Ø €€€Ø >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ø #Ð #Ð #Ð #Ð #Ð #Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'à )Ð )Ð )Ð )Ð )Ð )Ø &Ð &Ð &Ð &Ð &Ð &Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2ð1ð 1ð 1ð 1ð 1ð84ð 84ð 84ð 84ð 84ñ 84ô 84ð 84ðvMð Mð Mð Mð Mð` ˆzÒÐØ€J�L„L€L€L€Lð Ðr    