ó
r€
\c           @@ 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 „ Z d d	 „ Z e d
 k r˜ e ƒ  n  d S(   u  
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.

i    (   t   absolute_importt   print_functiont   unicode_literalsN(   t   __version__(   t   PY2(   t   UniversalDetectoru   stdinc         C@ sª   t  ƒ  } x4 |  D], } t | ƒ } | j | ƒ | j r Pq q W| j ƒ  | j } t rt | j t j	 ƒ  d ƒ } n  | d r™ d j
 | | d | d ƒ Sd j
 | ƒ Sd S(   uý   
    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
    u   ignoreu   encodingu   {0}: {1} with confidence {2}u
   confidenceu   {0}: no resultN(   R   t	   bytearrayt   feedt   donet   closet   resultR   t   decodet   syst   getfilesystemencodingt   format(   t   linest   namet   ut   lineR
   (    (    sK   /data/av2000/b2b/venv/lib/python2.7/site-packages/chardet/cli/chardetect.pyt   description_of   s    
		
	
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
 |  ƒ } xU | j D]J } | j ƒ  rÇ t d d d d d t j ƒn  t t | | j ƒ ƒ q“ Wd S(   uã   
    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
    t   descriptionuV   Takes one or more file paths and reports their detected                      encodingsu   inputt   helpu^   File whose encoding we would like to determine.                               (default: stdin)t   typeu   rbt   nargsu   *t   defaultu	   --versiont   actionu   versiont   versionu   %(prog)s {0}u0   You are running chardetect interactively. Press u8   CTRL-D twice at the start of a blank line to signal the u4   end of your input. If you want help, run chardetect u   --help
t   fileN(   t   argparset   ArgumentParsert   add_argumentt   FileTypeR   R   t   stdint   bufferR   R   t
   parse_argst   inputt   isattyt   printt   stderrR   R   (   t   argvt   parsert   argst   f(    (    sK   /data/av2000/b2b/venv/lib/python2.7/site-packages/chardet/cli/chardetect.pyt   main6   s    			u   __main__(   t   __doc__t
   __future__R    R   R   R   R   t   chardetR   t   chardet.compatR   t   chardet.universaldetectorR   R   t   NoneR+   t   __name__(    (    (    sK   /data/av2000/b2b/venv/lib/python2.7/site-packages/chardet/cli/chardetect.pyt   <module>   s   