zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
U
M±d8'ã@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œ}|dkrd}n(|dkr,d}n|dkr:d    }n td
|ƒ‚tj ||¡tƒ ¡}|dk    rx|d krx||S||krˆ||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 <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)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úXd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\charset_normalizer/cli/normalizer.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|  |¡}|jd2kr(|jd kr(td3tjd4d5S|jd2krR|jd krRtd6tjd4d5S|jd7ksj|jd8kr|td9tjd4d5Sg}|jD]ĉtˆ|j|jd:}| ¡‰ˆd;krtd< ˆj|jd8krÊd=nd>¡tjd4| ttˆjƒd;ggd?gd d8d7d;d2ƒ ¡n2| 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|jd2kr6ˆj 'dC¡d2krtdD ˆj¡tjd4ˆj(d kr†ˆ )¡q†t*t+ˆjƒƒ}t,t+ˆjƒƒ}| -dE¡}|jd kr^| .dFˆj¡ˆj(d kršˆ )¡n<|jd kršt/dG ˆj¡dHƒd kršˆj(d kr†ˆ )¡q†zHt0|dE 0|¡ƒ|dI_1t2|dIj1dJdKdL}| 3t4ˆƒ¡W5QRXWnRt5k
r4}    z2tt4|    ƒtjd4ˆj(d krˆ )¡WY¢dMSd;}    ~    XYnXˆj(d kr†ˆ )¡q†|j6d krtt7t%|ƒd5krzdNdA„|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.pyZOFFÚONz"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.)r4ÚexplainNz4Unable to identify originating encoding for "{}". {}z-Maybe try increasing maximum amount of chaos.rÚUnknowncsg|]}|ˆjkr|‘qSr©Úencoding©Ú.0Úcp)Ú
best_guessrr Ú
<listcomp>¹s
þzcli_detect.<locals>.<listcomp>csg|]}|ˆjkr|‘qSrr;r=)Úelrr rAÐ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-8r;écSsg|]
}|j‘qSr)Ú__dict__©r>rBrrr rAsé)Ú ensure_asciiÚindentz, cs&g|]}|jtˆjƒkr|jp d‘qS)Z    undefined)ÚpathrÚnamer<rI)Úmy_filerr rAsþ)9ÚargparseÚArgumentParserÚ add_argumentÚFileTypeÚfloatÚformatrrr Ú    md_moduleÚ__file__rÚendswithÚ
parse_argsr1r/ÚprintrÚstderrr2r4r$r r+ÚbestrNÚappendr rr<Zencoding_aliasesZcould_be_from_charsetÚlanguageZ    alphabetsÚbomZ percent_chaosZpercent_coherenceÚlenr.Ú
startswithÚclosedÚcloserrrÚsplitÚinsertr!rZ unicode_pathÚopenrÚstrÚIOErrorr0rrH)
r"ÚparserÚargsZx_ÚmatchesZdir_pathÚ    file_nameZo_ÚfpÚer)r@rBrOr Ú
cli_detect0sªÿÿú    úúúúúù    ü÷
 
ÿüù    õÿ
þñÿ
 
þñÿ ÿü 
 
ÿÿüúþ
    $ýÿ
 
þÿÿ
roÚ__main__)r)N) rPrÚjsonrÚos.pathrrrrrÚplatformrÚtypingr    r
Ú unicodedatar Zcharset_normalizer.mdZmdrVZcharset_normalizerr Zcharset_normalizer.modelsr Zcharset_normalizer.versionrrgÚboolr!ÚintroÚ__name__rrrr Ú<module>s       !x