
†Kðh—
  ã               @   sŸ   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 r› e ƒ  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  ƒ  } x1 |  D]) } t | ƒ } | j | ƒ | j r Pq W| j ƒ  | j } t rn | j t j	 ƒ  d ƒ } | d r“ d j
 | | d | d ƒ Sd j
 | ƒ Sd 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{}: {} with confidence {}Ú
confidencez{}: no resultN)r   Ú	bytearrayÚfeedÚdoneÚcloseÚresultr   ÚdecodeÚsysÚgetfilesystemencodingÚformat)ÚlinesÚnameÚuÚliner   © r   úR/mod/web/acousticsspace/venv/lib/python3.5/site-packages/chardet/cli/chardetect.pyÚdescription_of   s    
		
	
r   c          
   C   sâ   t  j d d ƒ } | j d d d d t  j d ƒ d d	 d
 t rH t j n	 t j j g ƒ| j d d d d d j t	 ƒ ƒ| j
 |  ƒ } xR | j D]G } | j ƒ  rÄ t d d d d d t j ƒt t | | j ƒ ƒ q“ Wd 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
    Ú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 {}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_argumentÚFileTyper   r   r   Úbufferr   r   Ú
parse_argsr   ÚisattyÚprintÚstderrr   r   )ÚargvÚparserÚargsÚfr   r   r   Úmain5   s    			r4   Ú__main__)Ú__doc__Ú
__future__r   r   r   r'   r   Úchardetr   Zchardet.compatr   Zchardet.universaldetectorr   r   r4   Ú__name__r   r   r   r   Ú<module>   s   