o
    Ëý°j»
  ã                   @   sv   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r9eƒ  dS 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   sv   t ƒ }| D ]}t|ƒ}| |¡ |jr nq| ¡  |j}tr'| t 	¡ d¡}|d r6d 
||d |d ¡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{}: {} with confidence {}Ú
confidencez{}: no result)r   Ú	bytearrayÚfeedÚdoneÚcloseÚresultr   ÚdecodeÚsysÚgetfilesystemencodingÚformat)ÚlinesÚnameÚuÚliner   © r   ú•/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pip/_vendor/chardet/cli/chardetect.pyÚdescription_of   s    

ÿÿ
r   c                 C   sŒ   t jdd�}|jddt  d¡dtrtjntjjgd� |jdd	d
 t	¡d� | 
| ¡}|jD ]}| ¡ r;tdtjd� tt||jƒƒ q.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 {})Úactionr$   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
)Ú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__)r   )N)Ú__doc__Ú
__future__r   r   r   r'   r   Úpip._vendor.chardetr   Úpip._vendor.chardet.compatr   Ú%pip._vendor.chardet.universaldetectorr   r   r4   Ú__name__r   r   r   r   Ú<module>   s    


ÿ