a ‚oe8'ã@sÐddlZddlZddlmZddlmZmZmZmZm Z ddl m Z ddl m Z mZddlmZddlmZddlmZddlmZdd lmZdeeed œd d „Zdee eedœdd„ZedkrÌeƒdS)éN)Údumps)ÚabspathÚbasenameÚdirnameÚjoinÚrealpath)Úpython_version)ÚListÚOptional)Úunidata_version)Úfrom_fp)ÚCliDetectionResult)Ú __version__Úyes)ÚquestionÚdefaultÚreturncCsšddddddœ}|durd}n(|dkr,d}n|dkr:d }n td |ƒ‚tj ||¡tƒ ¡}|durx|d krx||S||vrˆ||Stj d ¡qFdS) 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 . 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ÚyZyeÚnoÚnNz [y/n] rz [Y/n] rz [y/N] zinvalid default answer: '%s'Úz3Please respond with 'yes' or 'no' (or 'y' or 'n'). )Ú ValueErrorÚsysÚstdoutÚwriteÚinputÚlower)rrZvalidÚpromptÚchoice©rú@C:\Program Files\Certbot\pkgs\charset_normalizer\cli\__main__.pyÚ query_yes_nos   r!)Úargvrc sÒtjdd�}|jdt d¡ddd�|jdd d d d d d�|jddd d ddd�|jddd d ddd�|jddd d ddd�|jddd d ddd�|jdd d d d!d"d�|jd#d$d%d&td'd(d)�|jd*d+d, ttƒtt j   ¡  d-¡rèd.nd/¡d0d1�|  |¡}|jd2u�r(|jd u�r(td3tjd4�d5S|jd2u�rR|jd u�rRtd6tjd4�d5S|jd7k�sj|jd8k�r|td9tjd4�d5Sg}|jD�]؉tˆ|j|jd:�}| ¡‰ˆd;u�rtd< ˆj|jd8k�rÊd=nd>¡tjd4�| ttˆjƒd;ggd?gd d8d7d;d2ƒ ¡�nF| ttˆjƒˆjˆj‡fd@dA„ˆjDƒˆj ˆj!ˆj"ˆj#ˆj$d;d2ƒ ¡t%|ƒd5k�r¼|j&�r¼|D]V‰ˆˆk�rd| ttˆjƒˆjˆj‡fdBdA„ˆjDƒˆj ˆj!ˆj"ˆj#ˆj$d;d ƒ ¡�qd|jd2u�rJˆj 'dC¡d2u�rtdD ˆj¡tjd4�ˆj(d u�r†ˆ )¡�q†t*t+ˆjƒƒ}t,t+ˆjƒƒ}| -dE¡}|jd u�r^| .dFˆj¡ˆj(d u�ršˆ )¡n<|jd u�ršt/dG ˆj¡dHƒd u�ršˆj(d u�r†ˆ )¡�q†z^t0|dE 0|¡ƒ|dI_1t2|dIj1dJdKdL��}| 3t4ˆƒ¡Wd;ƒn1�sì0YWnPt5�yH} z6tt4| ƒtjd4�ˆj(d u�r0ˆ )¡WYd;} ~ dMSd;} ~ 00ˆj(d u�r†ˆ )¡�q†|j6d u�r¤tt7t%|ƒd5k�rŽdNdA„|Dƒn|dIj8d2dOdP�ƒn*|jD]"‰tdQ 0‡fdRdA„|Dƒ¡ƒ�qªdIS)Szˆ 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ú+zFile(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-tz --thresholdÚstoregš™™™™™É?Ú thresholdzUDefine a custom maximum amount of chaos allowed in decoded content. 0. <= chaos <= 1.)r,rr'r-r)z --versionÚversionz;Charset-Normalizer {} - Python {} - Unicode {} - SpeedUp {}z.pyZOFFZONz"Show version information and exit.)r,r5r)Tz.Use --replace in addition of --normalize only.)Úfileéz*Use --force in addition of --replace only.ggð?z---threshold VALUE should be between 0. AND 1.)r4ZexplainNz4Unable to identify originating encoding for "{}". {}z-Maybe try increasing maximum amount of chaos.rZUnknowncsg|]}|ˆjkr|‘qSr©Úencoding©Ú.0Zcp)Ú best_guessrr Ú ¹s þzcli_detect..csg|]}|ˆjkr|‘qSrr8r:)Úelrr r=Ðs þÚutfzJ"{}" file does not need to be normalized, as it already came from unicode.Ú.éÿÿÿÿz0Are you sure to normalize "{}" by replacing it ?rrÚwzutf-8r8écSsg|] }|j‘qSr)Ú__dict__©r;r>rrr r=óé)Z ensure_asciiÚindentz, cs&g|]}|jtˆjƒkr|jp d‘qS)Z undefined)ÚpathrÚnamer9rE)Úmy_filerr r=sþ)9ÚargparseÚArgumentParserÚ add_argumentÚFileTypeÚfloatÚformatrrr Ú md_moduleÚ__file__rÚendswithÚ parse_argsr1r/ÚprintrÚstderrr2r4r$r r+ZbestrJÚappendr rr9Zencoding_aliasesZcould_be_from_charsetÚlanguageZ alphabetsZbomZ percent_chaosZpercent_coherenceÚlenr.Ú startswithÚclosedÚcloserrrÚsplitÚinsertr!rZ unicode_pathÚopenrÚstrÚIOErrorr0rrD) r"ÚparserÚargsZx_ÚmatchesZdir_pathÚ file_nameZo_ÚfpÚer)r<r>rKr Ú cli_detect0s¤ÿÿú úúúúúù ü÷   ÿüù õÿ þñÿ  þñÿ ÿü     ÿÿüúþ 2    $ýÿ  þÿÿ riÚ__main__)r)N) rLrZjsonrZos.pathrrrrrÚplatformrÚtypingr r Ú unicodedatar Zcharset_normalizer.mdZmdrRZcharset_normalizerr Zcharset_normalizer.modelsr Zcharset_normalizer.versionrraÚboolr!ÚintriÚ__name__rrrr Ús       !x