VY² ã@sŸdZddlmZmZmZddlZddlZddlmZddl m Z ddl m Z ddd „Z dd d „Zed kr›eƒdS) 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ÚstdincCs¤tƒ}x1|D])}t|ƒ}|j|ƒ|jrPqW|jƒ|j}trn|jtj ƒdƒ}|dr“dj ||d|dƒSdj |ƒSdS)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}Z confidencez{0}: no resultN) rÚ bytearrayÚfeedÚdoneÚcloseÚresultrÚdecodeÚsysÚgetfilesystemencodingÚformat)ÚlinesÚnameÚuÚliner©rúL/tmp/pip-build-04bmskau/requests/requests/packages/chardet/cli/chardetect.pyÚdescription_ofs         rc Csâtjddƒ}|jddddtjdƒdd d trHtjn tjjgƒ|jd d d d djt ƒƒ|j |ƒ}xR|j D]G}|j ƒrÄt dddddtjƒt t||jƒƒq“WdS)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ÚFileTyperrrÚbufferrrÚ parse_argsrÚisattyÚprintÚstderrrr)ÚargvÚparserÚargsÚfrrrÚmain6s     r3Ú__main__)Ú__doc__Ú __future__rrrr&rÚchardetrZchardet.compatrÚchardet.universaldetectorrrr3Ú__name__rrrrÚs