
    #hf1                        S SK Jr  S SKrS SKrS SKrS SKJr  S SKJrJ	r	J
r
Jr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  S S	KJr  SSS
 jjr " S S5      rSSS jjr\S:X  a  \" 5         gg)    )annotationsN)dumps)abspathbasenamedirnamejoinrealpath)python_version)unidata_version)from_fp)CliDetectionResult)__version__c                @   SSSSSS.nUc  SnO US:X  a  SnOUS:X  a  SnO[        S	U-  5      e [        R                  R                  X-   5        [	        5       R                  5       nUb
  US
:X  a  X!   $ XB;   a  X$   $ [        R                  R                  S5        Mp  )a  Ask a yes/no question via input() and return their answer.

"question" is a string that is presented to the user.
"default" is the presumed answer if the user just hits <Enter>.
    It must be "yes" (the default), "no" or None (meaning
    an answer is required of the user).

The "answer" return value is True for "yes" or False for "no".

Credit goes to (c) https://stackoverflow.com/questions/3041986/apt-command-line-interface-like-yes-no-input
TF)yesyyenonz [y/n] r   z [Y/n] r   z [y/N] zinvalid default answer: '%s' z3Please respond with 'yes' or 'no' (or 'y' or 'n').
)
ValueErrorsysstdoutwriteinputlower)questiondefaultvalidpromptchoices        _/Users/user/Downloads/htwk/venv/lib/python3.13/site-packages/charset_normalizer/cli/__main__.pyquery_yes_nor"      s     t4u5IE	E		D7'ABB


*+6R<>!_= JJST     c                  P    \ rS rSrSr    S       S	S jjrS
S jrSS jrSrg)FileType2   a  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
Nc                4    Xl         X l        X0l        X@l        g N)_mode_bufsize	_encoding_errors)selfmodebufsizeencodingerrorss        r!   __init__FileType.__init__E   s     
!r#   c                P  ^  US:X  a  ST R                   ;   a:  ST R                   ;   a  [        R                  R                  $ [        R                  $ [	        U 4S jS 5       5      (       a:  ST R                   ;   a  [        R
                  R                  $ [        R
                  $ ST R                    3n[        U5      e [        UT R                   T R                  T R                  T R                  5      $ ! [         a#  nSU SU 3n[        R                  " U5      eS nAff = f)	N-rbc              3  @   >#    U  H  oTR                   ;   v   M     g 7fr(   )r)   ).0cr-   s     r!   	<genexpr>$FileType.__call__.<locals>.<genexpr>V   s     4e$**_es   waxzargument "-" with mode zcan't open 'z': )r)   r   stdinbufferanyr   r   openr*   r+   r,   OSErrorargparseArgumentTypeError)r-   stringmsgemessages   `    r!   __call__FileType.__call__Q   s    S=djj +.$**+<syy''K#))K4e444,/4::,=szz((M3::M/

|< o%	6

DMM4>>4<<XX 	6$VHCs3G,,W55	6s   6C8 8
D%D  D%c           
     `   U R                   U R                  4nSU R                  4SU R                  4/nSR	                  U Vs/ s H  o3S:w  d  M
  [        U5      PM     snU VVs/ s H  u  pCUc  M
  U SU< 3PM     snn-   5      n[        U 5      R                   SU S3$ s  snf s  snnf )Nr0   r1   , =())r)   r*   r+   r,   r   reprtype__name__)r-   argskwargsargkwargs_strs         r!   __repr__FileType.__repr__c   s    zz4==(t~~.4<<0HI99"&4$3)YT#Y$4.4Hf72"QsgfHI
 t*%%&az33 5Hs   	B%B%'	B*4B*)r*   r+   r,   r)   )r6   rM   NN)r.   strr/   intr0   
str | Noner1   r]   )rE   r[   returnz	typing.IO)r^   r[   )	rS   
__module____qualname____firstlineno____doc__r2   rI   rY   __static_attributes__ r#   r!   r%   r%   2   sJ    ( #!

 
 	

 
6$4r#   r%   c                `   [         R                  " SS9nUR                  S[        S5      SSS9  UR                  SS	S
SSSS9  UR                  SSS
SSSS9  UR                  SSS
SSSS9  UR                  SSS
SSSS9  UR                  SSS
SSSS9  UR                  SS S
SS!S"S9  UR                  S#S$S
SS%S&S9  UR                  S'S(S)S*[        S+S,S-9  UR                  S.S/S0R                  [        [        5       [        [        R                  R                  5       R                  S15      (       a  S2OS35      S4S59  UR                  U 5      nUR                  S6L a\  UR                  SL aM  UR                   (       a#  UR                    H  nUR#                  5         M     [%        S7[&        R(                  S89  g9UR*                  S6L a\  UR                  SL aM  UR                   (       a#  UR                    H  nUR#                  5         M     [%        S:[&        R(                  S89  g9UR,                  S;:  d  UR,                  S<:  aM  UR                   (       a#  UR                    H  nUR#                  5         M     [%        S=[&        R(                  S89  g9/ nUR                    GH;  n[/        UUR,                  UR0                  UR2                  SL S>9nUR5                  5       nUc}  [%        S@R                  UR6                  UR,                  S<:  a  SAOSB5      [&        R(                  S89  UR9                  [;        [=        UR6                  5      S?/ / SC/ SS<S;S?S65      5        GOYUR9                  [;        [=        UR6                  5      UR>                  UR@                  URB                   Vs/ s H  nXvR>                  :w  d  M  UPM     snURD                  URF                  URH                  URJ                  URL                  S?S65      5        [O        U5      S9:  a  URP                  (       a  U H  nX:w  d  M
  UR9                  [;        [=        UR6                  5      UR>                  UR@                  URB                   Vs/ s H  nXxR>                  :w  d  M  UPM     snURD                  URF                  URH                  URJ                  URL                  S?S5      5        M     UR                  S6L Ga  UR>                  RS                  SD5      S6L aS  [%        SER                  UR6                  5      [&        R(                  S89  URT                  SL a  UR#                  5         GM  [W        [Y        UR6                  5      5      n	[[        [Y        UR6                  5      5      n
U
R]                  SF5      nUR                  SL a<  UR_                  SGUR>                  5        URT                  SL a  UR#                  5         OYUR*                  SL aJ  [a        SHR                  UR6                  5      SI5      SL a"  URT                  SL a  UR#                  5         GM   [c        U	SFRc                  U5      5      USJ   l2        [g        USJ   Rd                  SK5       nURi                  URk                  5       5        S?S?S?5        URT                  SL d  GM+  UR#                  5         GM>     URp                  SL aM  [%        [s        [O        U5      S9:  a  U Vs/ s H  oRt                  PM     snOUSJ   Rt                  S6SMSN95        gJUR                    Hf  n[%        SORc                  U Vs/ s H=  nURv                  [=        UR6                  5      :X  d  M(  UR>                  =(       d    SPPM?     sn5      5        Mh     gJs  snf s  snf ! , (       d  f       GN= f! [l         aK  n[%        [o        U5      [&        R(                  S89  URT                  SL a  UR#                  5          S?nA  gLS?nAff = fs  snf s  snf )Qzx
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)rR   nargshelpz-vz	--verbose
store_trueFverbosezjDisplay complementary information about file if any. Stdout will contain logs about the detection process.)actionr   destrk   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.)rn   r   rR   ro   rk   z	--versionversionz;Charset-Normalizer {} - Python {} - Unicode {} - SpeedUp {}z.pyOFFONz"Show version information and exit.)rn   rx   rk   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.)rw   explainpreemptive_behaviourNz4Unable to identify originating encoding for "{}". {}z-Maybe try increasing maximum amount of chaos.r   UnknownutfzJ"{}" file does not need to be normalized, as it already came from unicode..rM   z0Are you sure to normalize "{}" by replacing it ?r   r   wb      )ensure_asciiindentrL   	undefined)<rC   ArgumentParseradd_argumentr%   floatformatr   r
   r   	md_module__file__r   endswith
parse_argsrs   rq   rg   closeprintr   stderrrt   rw   r   rm   ru   bestnameappendr   r   r0   encoding_aliasescould_be_from_charsetlanguage	alphabetsbompercent_chaospercent_coherencelenrp   
startswithclosedr   r	   r   splitinsertr"   r   unicode_pathrA   r   outputrB   r[   rr   r   __dict__path)argvparserrT   my_filex_matches
best_guesscpeldir_path	file_nameo_fprG   s                 r!   
cli_detectr   m   sp    $$%F htnC6N   @   X   [   Q   V   W   M   d   MTT''--/88??ET	
 2  
 T"D||t% 7:::: &>SZZPzzTdlle3:::: &:L~~t~~3:::: &=CJJO	B::nnLL!%!3!3u!<	
 \\^
FMMLL  >>C/ H ZZ
 II"GLL)  II"GLL)''// #-"B"B"BB!4!44 "B
 ''((NN,,00( 7|aD$5$5!B'		. ' 5 " " 3 3 /1.F.F!".F')[['8 %'.F!"
 !# " " " 0 0 " 4 4 $ % ", ~~%&&11%8D@dkk#LL !ZZ	 ~~."8GLL#9:$Xgll%;<	 ) 4<<5(IIb*"5"56~~.JJ%'$JQQ#LL 	  ~~.	)-h)EBqE&be00$72!2!2!45 8 >>U"MMOA D ||u.1"gkr*rr*r!u~~!	
&  zzG		 #%"$B77ggll&;; 32{2"$ " W.!"j 87 #a&szz2~~.	 +sa   '^2>^2<^7^7<_ ^<0_`&'`+	`+<
_	__
`#A ``#__main__)r   )r   r[   r   r[   r^   boolr(   )r   zlist[str] | Noner^   r\   )
__future__r   rC   r   typingjsonr   os.pathr   r   r   r   r	   platformr
   unicodedatar   charset_normalizer.mdmdr   charset_normalizerr   charset_normalizer.modelsr   charset_normalizer.versionr   r"   r%   r   rS   rd   r#   r!   <module>r      sY    "  
   > > # ' ) & 8 2UB84 84vL^ zL r#   