zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
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
U
L±dª ã@sŒdZddlZddlZddlmZmZmZddlmZddl    m
Z
dee e e e ee d    œd
d „Zdeee dd œd d„ZedkrˆeƒdS)a
Script which takes one or more file paths and reports on their detected
encodings
 
Example::
 
    % chardetect somefile someotherfile
    somefile: windows-1252 with confidence 0.5
    someotherfile: ascii with confidence 1.0
 
If no paths are provided, it takes its input from stdin.
 
éN)ÚIterableÚListÚOptionalé)Ú __version__)ÚUniversalDetectorÚstdinF)ÚlinesÚnameÚminimalÚshould_rename_legacyÚreturncCsxt|d}|D] }t|ƒ}| |¡|jrq0q| ¡|j}|rJ|dS|drn|›d|d›d|d›S|›dS)a°
    Return a string describing the probable encoding of a file or
    list of strings.
 
    :param lines: The lines to get the encoding of.
    :type lines: Iterable of bytes
    :param name: Name of file or collection of lines
    :type name: str
    :param should_rename_legacy:  Should we rename legacy encodings to
                                  their more modern equivalents?
    :type should_rename_legacy:   ``bool``
    )r Úencodingz: z with confidence Ú
confidencez : no result)rÚ    bytearrayÚfeedÚdoneÚcloseÚresult)r    r
r r ÚuÚliner©rúMd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\chardet/cli/chardetect.pyÚdescription_ofs
 
r)Úargvr cCs®tjdd}|jddt d¡dtjjgd|jdd    d
d |jd d dd
d |jdddt›d| |¡}|j    D]4}| 
¡rŽt dtj dt t ||j|j|jdƒqtdS)zã
    Handles command line arguments and gets things started.
 
    :param argv: List of arguments, as if specified on the command-line.
                 If None, ``sys.argv[1:]`` is used instead.
    :type argv: list of str
    zATakes one or more file paths and reports their detected encodings)Ú descriptionÚinputz@File whose encoding we would like to determine. (default: stdin)ÚrbÚ*)ÚhelpÚtypeÚnargsÚdefaultz    --minimalz*Print only the encoding to standard outputÚ
store_true)rÚactionz-lz--legacyz,Rename legacy encodings to more modern ones.z    --versionÚversionz    %(prog)s )r$r%z£You are running chardetect interactively. Press CTRL-D twice at the start of a blank line to signal the end of your input. If you want help, run chardetect --help
)Úfile)r r N)ÚargparseÚArgumentParserÚ add_argumentÚFileTypeÚsysrÚbufferrÚ
parse_argsrÚisattyÚprintÚstderrrr
r Úlegacy)rÚparserÚargsÚfrrrÚmain:sR    þûýüÿ
 
ûÿÿr5Ú__main__)rFF)N)Ú__doc__r'r+ÚtypingrrrÚrÚuniversaldetectorrÚbytesÚstrÚboolrr5Ú__name__rrrrÚ<module>s$  üû "5