ó •abc@s6dZddlmZddlZddlmZdZidd6d d 6d d 6d d6ZiZd„Z d„Z d„Z de fd„ƒYZ e dƒZe dƒZe dƒZdd„Zd„Zedd„Zdd„Zd„Zedd„Zd„Zd e fd!„ƒYZd"e fd#„ƒYZdS($u webencodings ~~~~~~~~~~~~ This is a Python implementation of the `WHATWG Encoding standard `. See README for details. :copyright: Copyright 2012 by Simon Sapin :license: BSD, see LICENSE for details. iÿÿÿÿ(tunicode_literalsNi(tLABELSu0.5u iso-8859-8u iso-8859-8-iu mac-cyrillicux-mac-cyrillicu mac-romanu macintoshucp874u windows-874cCs|jdƒjƒjdƒS(u9Transform (only) ASCII letters to lower case: A-Z is mapped to a-z. :param string: An Unicode string. :returns: A new Unicode string. This is used for `ASCII case-insensitive `_ matching of encoding labels. The same matching is also used, among other things, for `CSS keywords `_. This is different from the :meth:`~py:str.lower` method of Unicode strings which also affect non-ASCII characters, sometimes mapping them into the ASCII range: >>> keyword = u'Bac\N{KELVIN SIGN}ground' >>> assert keyword.lower() == u'background' >>> assert ascii_lower(keyword) != keyword.lower() >>> assert ascii_lower(keyword) == u'bac\N{KELVIN SIGN}ground' uutf8(tencodetlowertdecode(tstring((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyt ascii_lower#scCs¯t|jdƒƒ}tj|ƒ}|dkr4dStj|ƒ}|dkr«|dkrnddlm}n!tj||ƒ}t j |ƒ}t ||ƒ}|t|`_ algorithm. Supported labels are listed there. :param label: A string. :returns: An :class:`Encoding` object, or :obj:`None` for an unknown label. u ux-user-definedi(t codec_infoN( RtstripRtgettNonetCACHEtx_user_definedRt PYTHON_NAMEStcodecstlookuptEncoding(tlabeltnametencodingRt python_name((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyR=s     cCsBt|dƒr|St|ƒ}|dkr>td|ƒ‚n|S(uç Accept either an encoding object or label. :param encoding: An :class:`Encoding` object or a label string. :returns: An :class:`Encoding` object. :raises: :exc:`~exceptions.LookupError` for an unknown label. u codec_infouUnknown encoding label: %rN(thasattrRR t LookupError(tencoding_or_labelR((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyt _get_encoding[s   RcBs eZdZd„Zd„ZRS(uOReresents a character encoding such as UTF-8, that can be used for decoding or encoding. .. attribute:: name Canonical name of the encoding .. attribute:: codec_info The actual implementation of the encoding, a stdlib :class:`~codecs.CodecInfo` object. See :func:`codecs.register`. cCs||_||_dS(N(RR(tselfRR((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyt__init__|s cCs d|jS(Nu (R(R((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyt__repr__€s(t__name__t __module__t__doc__RR(((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyRms uutf-8uutf-16leuutf-16beureplacecCsGt|ƒ}t|ƒ\}}|p'|}|jj||ƒd|fS(uÖ Decode a single string. :param input: A byte string :param fallback_encoding: An :class:`Encoding` object or a label string. The encoding to use if :obj:`input` does note have a BOM. :param errors: Type of error handling. See :func:`codecs.register`. :raises: :exc:`~exceptions.LookupError` for an unknown encoding label. :return: A ``(output, encoding)`` tuple of an Unicode string and an :obj:`Encoding`. i(Rt _detect_bomRR(tinputtfallback_encodingterrorst bom_encodingR((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyR‹s  cCsa|jdƒrt|dfS|jdƒr:t|dfS|jdƒrWt|dfSd|fS(uBReturn (bom_encoding, input), with any BOM removed from the input.sÿþisþÿsiN(t startswitht_UTF16LEt_UTF16BEtUTF8R (R ((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyR¡sustrictcCst|ƒjj||ƒdS(u; Encode a single string. :param input: An Unicode string. :param encoding: An :class:`Encoding` object or a label string. :param errors: Type of error handling. See :func:`codecs.register`. :raises: :exc:`~exceptions.LookupError` for an unknown encoding label. :return: A byte string. i(RRR(R RR"((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyR¬s cCs4t||ƒ}t||ƒ}t|ƒ}||fS(uâ "Pull"-based decoder. :param input: An iterable of byte strings. The input is first consumed just enough to determine the encoding based on the precense of a BOM, then consumed on demand when the return value is. :param fallback_encoding: An :class:`Encoding` object or a label string. The encoding to use if :obj:`input` does note have a BOM. :param errors: Type of error handling. See :func:`codecs.register`. :raises: :exc:`~exceptions.LookupError` for an unknown encoding label. :returns: An ``(output, encoding)`` tuple. :obj:`output` is an iterable of Unicode strings, :obj:`encoding` is the :obj:`Encoding` that is being used. (tIncrementalDecodert_iter_decode_generatortnext(R R!R"tdecodert generatorR((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyt iter_decodeºs ccsî|j}t|ƒ}x‡|D]>}||ƒ}|r|jdk sIt‚|jV|VPqqW|ddtƒ}|jdk s…t‚|jV|r›|VndSx(|D] }||ƒ}|r¦|Vq¦q¦W|ddtƒ}|rê|VndS(uqReturn a generator that first yields the :obj:`Encoding`, then yields output chukns as Unicode strings. ttfinalN(RtiterRR tAssertionErrortTrue(R R+Rtchuncktoutput((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyR)Ös,       cCst||ƒj}t||ƒS(uY “Pullâ€-based encoder. :param input: An iterable of Unicode strings. :param encoding: An :class:`Encoding` object or a label string. :param errors: Type of error handling. See :func:`codecs.register`. :raises: :exc:`~exceptions.LookupError` for an unknown encoding label. :returns: An iterable of byte strings. (tIncrementalEncoderRt_iter_encode_generator(R RR"R((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyt iter_encodeös ccsOx(|D] }||ƒ}|r|VqqW|ddtƒ}|rK|VndS(NuR/(R2(R RR3R4((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyR6s   R(cBs&eZdZdd„Zed„ZRS(uO “Pushâ€-based decoder. :param fallback_encoding: An :class:`Encoding` object or a label string. The encoding to use if :obj:`input` does note have a BOM. :param errors: Type of error handling. See :func:`codecs.register`. :raises: :exc:`~exceptions.LookupError` for an unknown encoding label. ureplacecCs7t|ƒ|_||_d|_d|_d|_dS(NR.(Rt_fallback_encodingt_errorst_bufferR t_decoderR(RR!R"((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyRs    cCs¶|j}|dk r"|||ƒS|j|}t|ƒ\}}|dkrt|ƒdkrs| rs||_dS|j}n|jj|jƒj }||_||_ |||ƒS(uùDecode one chunk of the input. :param input: A byte string. :param final: Indicate that no more input is available. Must be :obj:`True` if this is the last call. :returns: An Unicode string. iuN( R;R R:RtlenR8RtincrementaldecoderR9RR(RR R/R+R((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyR's         (RRRRtFalseR(((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyR(s  R5cBseZdZedd„ZRS(uù “Pushâ€-based encoder. :param encoding: An :class:`Encoding` object or a label string. :param errors: Type of error handling. See :func:`codecs.register`. :raises: :exc:`~exceptions.LookupError` for an unknown encoding label. .. method:: encode(input, final=False) :param input: An Unicode string. :param final: Indicate that no more input is available. Must be :obj:`True` if this is the last call. :returns: A byte string. ustrictcCs(t|ƒ}|jj|ƒj|_dS(N(RRtincrementalencoderR(RRR"((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyRTs (RRRR'R(((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyR5Cs(Rt __future__RRtlabelsRtVERSIONR R RRRtobjectRR'R%R&RRRR-R)R7R6R(R5(((sE/usr/lib/python2.7/site-packages/pip/_vendor/webencodings/__init__.pyt s4             3