Viewing File: /opt/alt/python35/lib/python3.5/site-packages/chardet/cli/__pycache__/chardetect.cpython-35.pyc



<_9Y²
ã@sŸdZddlmZmZmZddlZddlZddlmZddl	m
Z
ddlmZddd	„Z
dd
d„Zedkr›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.

é)Úabsolute_importÚprint_functionÚunicode_literalsN)Ú__version__)ÚPY2)ÚUniversalDetectorÚstdincCs¤tƒ}x1|D])}t|ƒ}|j|ƒ|jrPqW|jƒ|j}trn|jtj	ƒdƒ}|dr“dj
||d|dƒSdj
|ƒSdS)zý
    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
    ÚignoreÚencodingz{0}: {1} with confidence {2}Z
confidencez{0}: no resultN)rÚ	bytearrayZfeedÚdoneÚcloseÚresultrÚdecodeÚsysÚgetfilesystemencodingÚformat)ÚlinesÚnameÚuÚliner©rú/chardetect.pyÚdescription_ofs
	

	
	
rc
Csâtjddƒ}|jddddtjdƒdd	d
trHtjn	tjjgƒ|jddd
d
djt	ƒƒ|j
|ƒ}xR|jD]G}|jƒrÄt
dddddtjƒt
t||jƒƒq“WdS)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
    ÚdescriptionzVTakes one or more file paths and reports their detected                      encodingsÚinputÚhelpz^File whose encoding we would like to determine.                               (default: stdin)ÚtypeÚrbÚnargsÚ*Údefaultz	--versionÚactionÚversionz%(prog)s {0}z0You are running chardetect interactively. Press z8CTRL-D twice at the start of a blank line to signal the z4end of your input. If you want help, run chardetect z--help
ÚfileN)ÚargparseÚArgumentParserÚadd_argumentZFileTyperrrÚbufferrrÚ
parse_argsrÚisattyÚprintÚstderrrr)ÚargvÚparserÚargsÚfrrrÚmain6s			r1Ú__main__)Ú__doc__Z
__future__rrrr%rZchardetrZchardet.compatrZchardet.universaldetectorrrr1Ú__name__rrrrÚ<module>s
Back to Directory File Manager