
    wg(                        d dl mZ d dlZd dlZd dlm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dddZedk(  r e        yy)    )annotationsN)dumps)abspathbasenamedirnamejoinrealpath)python_version)unidata_version)from_fp)CliDetectionResult)__version__c                8   dddddd}|d}n|dk(  rd}n|dk(  rd}nt        d	|z        	 t        j                  j                  | |z          t	               j                         }|
|d
k(  r||   S ||v r||   S t        j                  j                  d       o)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        d/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/charset_normalizer/cli/__main__.pyquery_yes_nor"      s     t4u5IE	E		D7'ABB


F*+6R<>!u_= JJVW     c                ,   t        j                  d      }|j                  dt        j                  d      dd       |j                  dd	d
ddd       |j                  ddd
ddd       |j                  ddd
ddd       |j                  ddd
ddd       |j                  ddd
ddd       |j                  dd d
dd!d"       |j                  d#d$d
dd%d&       |j                  d'd(d)d*t        d+d,-       |j                  d.d/d0j                  t        t               t        t        j                  j                         j                  d1      rd2nd3      d45       |j                  |       }|j                  d6u rW|j                  du rI|j                   r!|j                   D ]  }|j#                           t%        d7t&        j(                  8       y9|j*                  d6u rW|j                  du rI|j                   r!|j                   D ]  }|j#                           t%        d:t&        j(                  8       y9|j,                  d;k  s|j,                  d<kD  rI|j                   r!|j                   D ]  }|j#                           t%        d=t&        j(                  8       y9g }|j                   D ]"  }t/        ||j,                  |j0                  |j2                  du >      }|j5                         }|t%        d@j                  |j6                  |j,                  d<k  rdAndB      t&        j(                  8       |j9                  t;        t=        |j6                        d?g g dCg dd<d;d?d6             n?|j9                  t;        t=        |j6                        |j>                  |j@                  |jB                  D cg c]  }||j>                  k7  r| c}|jD                  |jF                  |jH                  |jJ                  |jL                  d?d6             tO        |      d9kD  r|jP                  r|D ]  }||k7  s	|j9                  t;        t=        |j6                        |j>                  |j@                  |jB                  D cg c]  }||j>                  k7  r| c}|jD                  |jF                  |jH                  |jJ                  |jL                  d?d              |j                  d6u r|j>                  jS                  dD      d6u rTt%        dEj                  |j6                        t&        j(                  8       |jT                  du r|j#                          tW        tY        |j6                              }	t[        tY        |j6                              }
|
j]                  dF      }|j                  du r;|j_                  dG|j>                         |jT                  du rf|j#                          nU|j*                  du rGta        dHj                  |j6                        dI      du r |jT                  du r|j#                          	 tc        |	dFjc                  |            |dJ   _2        tg        |dJ   jd                  dK      5 }|ji                  |jk                                d?d?d?       |jT                  du s|j#                          % |jp                  du rMt%        ts        tO        |      d9kD  r|D cg c]  }|jt                   c}n|dJ   jt                  d6dMN             yJ|j                   D ]Z  }t%        dOjc                  |D cg c]4  }|jv                  t=        |j6                        k(  r|j>                  xs dP6 c}             \ yJc c}w c c}w # 1 sw Y   xY w# tl        $ rM}t%        to        |      t&        j(                  8       |jT                  du r|j#                          Y d?}~ yLd?}~ww xY wc c}w c c}w )Qz
    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)typenargshelpz-vz	--verbose
store_trueFverbosezjDisplay complementary information about file if any. Stdout will contain logs about the detection process.)actionr   destr+   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.)r.   r   r)   r/   r+   z	--versionversionz;Charset-Normalizer {} - Python {} - Unicode {} - SpeedUp {}z.pyOFFONz"Show version information and exit.)r.   r8   r+   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.)r7   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..z0Are you sure to normalize "{}" by replacing it ?r   r   wb      )ensure_asciiindentz, 	undefined)<argparseArgumentParseradd_argumentFileTypefloatformatr   r
   r   	md_module__file__r   endswith
parse_argsr3   r1   r&   closeprintr   stderrr4   r7   r   r-   r5   bestnameappendr   r   encodingencoding_aliasescould_be_from_charsetlanguage	alphabetsbompercent_chaospercent_coherencelenr0   
startswithclosedr   r	   r   splitinsertr"   r   unicode_pathopenr   outputOSErrorstrr2   r   __dict__path)argvparserargsmy_filex_matches
best_guesscpeldir_path	file_nameo_fpes                 r!   
cli_detectr{   1   s    $$%F h''-S?W   @   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!4!44 
 ''((NN,,00( 7|aD$5$5! BZ'		. ' 5 " " 3 3 /1.F.F!"(*')R[['8 %'!"
 !# " " " 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$7 62!2!2!456 >>U"MMOA@D ||u.1"gkr**r!u~~!	
&  zz 		G		 #%77ggll&;; 2{2		 W.!"j6 6 #a&szz2~~.	 +sI   >^^"<^3 ^'-^3`9`'^0	,^33	`	<A``	__main__)r   )r   rj   r   rj   returnbool)N)rm   zlist[str] | Noner}   int)
__future__r   rI   r   jsonr   os.pathr   r   r   r   r	   platformr
   unicodedatar   charset_normalizer.mdmdrO   charset_normalizerr   charset_normalizer.modelsr   charset_normalizer.versionr   r"   r{   __name__ r#   r!   <module>r      sK    "  
  > > # ' ) & 8 2XBL^ zL r#   