o {nhf1@sddlmZddlZddlZddlZddlmZddlmZm Z m Z m Z m Z ddl mZddlmZddlmZddlmZddlmZdd lmZddddZGdddZddddZedkrfedSdS)) annotationsN)dumps)abspathbasenamedirnamejoinrealpath)python_version)unidata_version)from_fp)CliDetectionResult) __version__yesquestionstrdefaultreturnboolcCsdddddd}|durd}n|dkrd}n |dkrd }ntd | tj||t}|dur=|d kr=||S||vrE||Stjd q$) 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)rrvalidpromptchoicer"J/usr/local/lib/python3.10/dist-packages/charset_normalizer/cli/__main__.py query_yes_nos"    r$c@s8eZdZdZ    ddd d ZdddZdddZdS)FileTypeaFactory for creating file object types Instances of FileType are typically passed as type= arguments to the ArgumentParser add_argument() method. Keyword Arguments: - mode -- A string indicating how the file is to be opened. Accepts the same values as the builtin open() function. - bufsize -- The file's desired buffer size. Accepts the same values as the builtin open() function. - encoding -- The file's encoding. Accepts the same values as the builtin open() function. - errors -- A string indicating how encoding and decoding errors are to be handled. Accepts the same value as the builtin open() function. Backported from CPython 3.12 rNmoderbufsizeintencoding str | NoneerrorscCs||_||_||_||_dSN)_mode_bufsize _encoding_errors)selfr(r)r+r-r"r"r#__init__Es zFileType.__init__stringr typing.IOc s|dkr6djvrdjvrtjjStjStfdddDr,djvr)tjjStjSdj}t|z t|jjj j WSt y\}z d|d |}t |d}~ww) N-r&bc3s|]}|jvVqdSr.)r/).0cr3r"r# Vsz$FileType.__call__..waxzargument "-" with mode z can't open 'z': )r/rstdinbufferanyrropenr0r1r2OSErrorargparseArgumentTypeError)r3r5msgemessager"r;r#__call__Qs   zFileType.__call__cCsX|j|jf}d|jfd|jfg}ddd|Ddd|D}t|jd|dS) Nr+r-, cSsg|] }|dkrt|qS)r')repr)r9argr"r"r# gsz%FileType.__repr__..cSs&g|]\}}|dur|d|qS)N=r")r9kwrKr"r"r#rLhs&())r/r0r1r2rtype__name__)r3argskwargsargs_strr"r"r#__repr__cs   zFileType.__repr__)r&r'NN)r(rr)r*r+r,r-r,)r5rrr6)rr)rR __module__ __qualname____doc__r4rHrVr"r"r"r#r%2s r%argvlist[str] | Noner*c s(tjdd}|jdtdddd|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 d%d&d|jd'd(d)d*td+d,d-|jd.d/d0tttt j d1r~d2nd3d4d5| |}|jd6ur|jd ur|jr|jD]qtd7tjd8d9S|jd6ur|jd ur|jr|jD]qtd:tjd8d9S|jd;ks|jd}|d?ur1td@j|jdDisable looking at a charset declaration to hint the detector.z-tz --thresholdstoreg? thresholdzUDefine a custom maximum amount of noise allowed in decoded content. 0. <= noise <= 1.)rdrrQreraz --versionversionz;Charset-Normalizer {} - Python {} - Unicode {} - SpeedUp {}z.pyOFFONz"Show version information and exit.)rdrnraTz.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.)rmexplainpreemptive_behaviourNz4Unable to identify originating encoding for "{}". {}z-Maybe try increasing maximum amount of chaos.rUnknowncg|] }|jkr|qSr"r+r9cp) best_guessr"r#rL  zcli_detect..crvr"rwrx)elr"r#rL%r{utfzJ"{}" file does not need to be normalized, as it already came from unicode..r'z0Are you sure to normalize "{}" by replacing it ?rrwbcSsg|]}|jqSr")__dict__r9r|r"r"r#rLhs) ensure_asciiindentrIcs&g|]}|jtjkr|jpdqS) undefined)pathrnamer+r)my_filer"r#rLqs );rCArgumentParser add_argumentr%floatformatr r r md_module__file__rendswith parse_argsrirgr]closeprintrstderrrjrmr rcrkbestrappendr rr+encoding_aliasescould_be_from_charsetlanguage alphabetsbom percent_chaospercent_coherencelenrf startswithclosedrrrsplitinsertr$r unicode_pathrAroutputrBrrhrr) rZparserrSx_matchesdir_path file_nameo_fprFr")rzr|rr# cli_detectms                           $   r__main__)r)rrrrrrr.)rZr[rr*) __future__rrCrtypingjsonros.pathrrrrrplatformr unicodedatar charset_normalizer.mdmdrcharset_normalizerr charset_normalizer.modelsr charset_normalizer.versionr r$r%rrRr"r"r"r#s(         ! ;