id1%ddlZddlZddlmZddlmZddlmZddlm Z m Z  ddl m Z n#e $r ddlm Z YnwxYwddlmZddlmZdd lmZdd ed ed efdZdde e ed efdZedkr edSdS)N)dumps)abspath)python_version)ListOptional)unidata_version)from_fp)CliDetectionResult) __version__yesquestiondefaultreturncbdddddd}|d}n$|dkrd}n|dkrd }ntd |z tj||zt }||d kr||S||vr||Stjd ~) aAsk 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 . 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)r yyenonNz [y/n] r z [Y/n] rz [y/N] zinvalid default answer: '%s'z3Please respond with 'yes' or 'no' (or 'y' or 'n'). ) ValueErrorsysstdoutwriteinputlower)r rvalidpromptchoices V/opt/cloudlinux/venv/lib/python3.11/site-packages/charset_normalizer/cli/normalizer.py query_yes_nor st4u5 I IE E   D7'ABBBX F*+++  6R<<> ! u__= J  V W W WXargvc  tjd}|dtjddd|dd d d d d |ddd d dd|ddd d dd|ddd d dd|ddd d dd|dd d d d!d"|d#d$d%d&td'd()|d*d+d,t ttd-.| |}|j d/ur&|j d urtd0tj1d2S|jd/ur&|j d urtd3tj1d2S|jd4ks |jd5krtd6tj1d2Sg}|jD] t% |j|j7}|td9 j|jd5krd:nd;tj1|t/t1 jd8ggd jD j j j j j d8d {|j d/urj#d?d/urRtd@ jtj1 j$d ur %7 j&dA}|j d ur9|'dBj j$d ur %nR|jd urItQdC jdDd ur j$d ur % t1dEdA)||dF_*tW|dFj*dGdHI5}|,t[d8d8d8n #1swxYwYn^#t\$rQ}tt[|tj1 j$d ur %Yd8}~dJSd8}~wwxYw j$d ur %|j/d urJttatC|d2kr dK|Dn |dFj1d/dLMn8|jD]0 tdN) fdO|D1dFS)Pz 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.) descriptionfilesrb+zFile(s) to be analysed)typenargshelpz-vz --verbose store_trueFverbosezjDisplay complementary information about file if any. Stdout will contain logs about the detection process.)actionrdestr*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 --minimalminimalzBOnly output the charset detected to STDOUT. Disabling JSON output.z-rz --replacereplacezGReplace file when trying to normalize it instead of creating a new one.z-fz--forceforcezHReplace file without asking if you are sure, use this flag with caution.z-tz --thresholdstoreg? thresholdzUDefine a custom maximum amount of chaos allowed in decoded content. 0. <= chaos <= 1.)r-rr(r.r*z --versionversionz.Charset-Normalizer {} - Python {} - Unicode {}z"Show version information and exit.)r-r6r*Tz.Use --replace in addition of --normalize only.)filez*Use --force in addition of --replace only.gg?z---threshold VALUE should be between 0. AND 1.)r5explainNz4Unable to identify originating encoding for "{}". {}z-Maybe try increasing maximum amount of chaos.rUnknownc*g|]}|jk |Sencoding).0cp best_guesss r zcli_detect..s1!444444r!c*g|]}|jk |Sr<r=)r?r@els rrBzcli_detect..s0!"!"!"(*')R['8'8%''8'8'8r!utfzJ"{}" file does not need to be normalized, as it already came from unicode..z0Are you sure to normalize "{}" by replacing it ?rz./{}rwzutf-8r=cg|] }|j Sr<)__dict__)r?rDs rrBzcli_detect..s******r!) ensure_asciiindentz, c\g|](}|jtjk|jpd)S) undefined)pathrnamer>)r?rDmy_files rrBzcli_detect..sA7ggl&;&;;; 2{;;;r!)2argparseArgumentParser add_argumentFileTypefloatformatr rr parse_argsr2r0printrstderrr3r5r%r r,bestrRappendr rr>encoding_aliasescould_be_from_charsetlanguage alphabetsbom percent_chaospercent_coherencelenr/ startswithclosedclosesplitinsertr join unicode_pathopenrstrIOErrorr1rrK) r"parserargsx_matcheso_fperArDrSs @@@r cli_detectrx3s  $%F  h'--S?W   @     X     [     Q     V     W      d @GG ))?  2    T " "D |t% 7 7 >SZPPPPq zTdle33 :LLLLq ~t~33 =CJOOOOq B:xx'T^T\RRR\\^^   FMML~++DC  Z     II"GL))       II"GL))'/","B '(N,0   (7||aD$5!BZ'' . ' 5 5 " " 3!"!"!"!".0.F!"!"!" !# " " " 0 " 4 $ %(~%%&11%88D@@dkk#L!Z  ~..  ' 2 23 7 7<5((IIb*"5666~.. J%''$JQQ#L   ~..  )0sxx||1L1L)M)MBqE&be0#HHH2BZ111222222222222222#a&&sz2222~.. 111111  >U " " MMOOO |u .1"ggkk**r****r!u~!       z  G  "$     1s> AU8=#U, U8,U0 0U83U0 4U88 WAWW__main__)r )N)rTrjsonros.pathrplatformrtypingrr unicodedata2r ImportError unicodedatacharset_normalizerr charset_normalizer.modelsr charset_normalizer.versionr roboolr intrx__name__r<r!rrs} ######!!!!!!!!,,,,,,,,,,,++++++++,'&&&&&888888222222XX3XXXXXXBp p Xd3i(p Cp p p p f zJLLLLLs + 99