
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
ÝPf²
  ã               @   sr   d Z ddlmZmZmZ ddlZddlZddlmZ ddl	m
Z
 ddlmZ ddd	„Zdd
d„Zedkrneƒ  dS )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Ústdinc             C   s|   t ƒ }x&| D ]}t|ƒ}|j|ƒ |jrP qW |jƒ  |j}trP|jtj	ƒ dƒ}|d rndj
||d |d ƒS dj
|ƒS dS )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   Ú	bytearrayZfeedÚdoneÚcloseÚresultr   ÚdecodeÚsysÚgetfilesystemencodingÚformat)ÚlinesÚnameÚuÚliner   © r   ú /usr/lib/python3.6/chardetect.pyÚdescription_of   s    



r   c             C   s�   t jdd�}|jddt jdƒdtr(tjntjjgd� |jdd	d
jt	ƒd� |j
| ƒ}x4|jD ]*}|jƒ rxtdtjd� tt||jƒƒ q^W dS )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
    zVTakes 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	--versionÚversionz%(prog)s {0})Úactionr"   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
)ÚfileNzhYou are running chardetect interactively. Press CTRL-D twice at the start of a blank line to signal the 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 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
)ÚargparseÚArgumentParserÚadd_argumentZFileTyper   r   r   Úbufferr   r   Ú
parse_argsr   ÚisattyÚprintÚstderrr   r   )ÚargvÚparserÚargsÚfr   r   r   Úmain6   s    	

 r1   Ú__main__)r   )N)Ú__doc__Z
__future__r   r   r   r%   r   Zchardetr   Zchardet.compatr   Zchardet.universaldetectorr   r   r1   Ú__name__r   r   r   r   Ú<module>   s   

