File: //opt/alt/python27/lib/python2.7/site-packages/chardet/chardetect.pyc
�
�m-Xc           @@ 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   open(   t   __version__(   t   UniversalDetectoru   stdinc         C@ sp   t  �  } x |  D] } | j | � q W| j �  | j } | 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   encodingu   {0}: {1} with confidence {2}u
   confidenceu   {0}: no resultN(   R   t   feedt   closet   resultt   format(   t   linest   namet   ut   lineR   (    (    sC   /opt/alt/python27/lib/python2.7/site-packages/chardet/chardetect.pyt   description_of   s    
	
	
c      
   C@ s�   t  j d d d t  j d d � } | j d d d d	 t  j d
 � d d d
 t 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                      encodingst   formatter_classt   conflict_handleru   resolveu   inputt   helpu/   File whose encoding we would like to determine.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   ArgumentDefaultsHelpFormattert   add_argumentt   FileTypet   syst   stdinR	   R   t
   parse_argst   inputt   isattyt   printt   stderrR   R   (   t   argvt   parsert   argst   f(    (    sC   /opt/alt/python27/lib/python2.7/site-packages/chardet/chardetect.pyt   main/   s"