‹“ReÖ
ã @ 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{0}: {1} with confidence {2}Ú
confidencez{0}: no resultN)r Ú bytearrayÚfeedÚdoneÚcloseÚresultr ÚdecodeÚsysÚgetfilesystemencodingÚformat)ÚlinesÚnameÚuÚliner © r ú‘/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-5.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/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 {0}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 Úmain6 s r4 Ú__main__)Ú__doc__Ú
__future__r r r r' r Zpip._vendor.chardetr Zpip._vendor.chardet.compatr Ú%pip._vendor.chardet.universaldetectorr r r4 Ú__name__r r r r Ú