c&ddlZddlZddlmZddlmZmZmZmZm Z ddl m Z ddl m Z mZddlmZddlmZddlmZddlmZdd lmZdd ed ed efdZddee ed efdZedkr edSdS)N)dumps)abspathbasenamedirnamejoinrealpath)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)ryyenonNz [y/n] rz [Y/n] rz [y/N] zinvalid default answer: '%s'z3Please respond with 'yes' or 'no' (or 'y' or 'n'). ) ValueErrorsysstdoutwriteinputlower)rrvalidpromptchoices C/usr/lib/python3/dist-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 tttj d-rd.nd/d01| |}|jd2ur&|jd urt!d3t"j4d5S|jd2ur&|jd urt!d6t"j4d5S|jd7ks |jd8krt!d9t"j4d5Sg}|jD]$ t- |j|j:}| t!d< j|jd8krd=nd>t"j4|t7t9 jd;ggd?gd d8d7d;d2 nQ|t7t9 j j j fd@ jD j j! j" j# j$d;d2 tK|d5kr|j&r}|D]z krr|t7t9 j j j fdA jD j j! j" j# j$d;d {|jd2ur> j'dBd2urRt!dC jt"j4 j(d ur )7tUtW j}tYtW j}|-dD}|jd ur9|.dE j j(d ur )nR|jd urIt_dF jdGd ur j(d ur )" ta|dD0||dH_1te|dHj1dIdJK5}|3ti d;d;d;n #1swxYwYn^#tj$rQ} t!ti| t"j4 j(d ur )Yd;} ~ dLSd;} ~ wwxYw j(d ur )&|j6d urJt!totK|d5kr dM|Dn |dHj8d2dNOn8|jD]0 t!dP0 fdQ|D1dHS)Rz 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.)r1rr,r2r.z --versionversionz;Charset-Normalizer {} - Python {} - Unicode {} - SpeedUp {}z.pyOFFONz"Show version information and exit.)r1r:r.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.)r9explainNz4Unable 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 |SrBrC)rErFels r#rHzcli_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 ?rrwzutf-8rCcg|] }|j SrB)__dict__)rErJs r#rHzcli_detect..s******r%) ensure_asciiindentz, c\g|](}|jtjk|jpd)S) undefined)pathrnamerD)rErJmy_files r#rHzcli_detect..sA7ggl&;&;;; 2{;;;r%)9argparseArgumentParser add_argumentFileTypefloatformatrr r md_module__file__rendswith parse_argsr6r4printrstderrr7r9r)r r0bestrXappendrrrDencoding_aliasescould_be_from_charsetlanguage alphabetsbom percent_chaospercent_coherencelenr3 startswithclosedcloserrrsplitinsertr$r unicode_pathopenrstrIOErrorr5rrQ) r&parserargsx_matchesdir_path file_nameo_fperGrJrYs @@@r# cli_detectr0sh  $%F  h'--S?W   @     X     [     Q     V     W      d MTT     '--//88?? IEET   2      T " "D |t% 7 7 >SZPPPPq zTdle33 :LLLLq ~t~33 =CJOOOOq B:{{'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  ~.. "8GL#9#9::$Xgl%;%;<< ) 4 4<5((IIb*"5666~.. J%''$JQQ#L   ~..  )-h )E)EBqE&be0#HHH2BZ111222222222222222#a&&sz2222~.. 111111  >U " " MMOOO |u .1"ggkk**r****r!u~!       z  G  "$     1s>A W#W ? W W WW W X2!AX--X2__main__)r)N) rZrjsonros.pathrrrrrplatformr typingr r unicodedatar charset_normalizer.mdmdr`charset_normalizerr charset_normalizer.modelsrcharset_normalizer.versionrrwboolr$intr__name__rBr%r#rsj >>>>>>>>>>>>>>######!!!!!!!!''''''))))))&&&&&&888888222222XX3XXXXXXBv v Xd3i(v Cv v v v r zJLLLLLr%