Viewing File: /opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/webencodings/__init__.pyc

ó
“tÆ_c@s6dZddlmZddlZddlmZdZidd6d	d
6dd6d
d6ZiZd„Z	d„Z
d„Zde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
    <http://encoding.spec.whatwg.org/>`. See README for details.

    :copyright: Copyright 2012 by Simon Sapin
    :license: BSD, see LICENSE for details.

iÿÿÿÿ(tunicode_literalsNi(tLABELSu0.5.1u
iso-8859-8uiso-8859-8-iumac-cyrillicux-mac-cyrillicu	mac-romanu	macintoshucp874uwindows-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
    <http://encoding.spec.whatwg.org/#ascii-case-insensitive>`_
    matching of encoding labels.
    The same matching is also used, among other things,
    for `CSS keywords <http://dev.w3.org/csswg/css-values/#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((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/webencodings/__init__.pytascii_lower#scCs¯t|jdƒƒ}tj|ƒ}|dkr4dStj|ƒ}|dkr«|dkrnddlm}n!tj||ƒ}t	j
|ƒ}t||ƒ}|t|<n|S(u<
    Look for an encoding by its label.
    This is the spec’s `get an encoding
    <http://encoding.spec.whatwg.org/#concept-encoding-get>`_ 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(tlabeltnametencodingRtpython_name((sR/opt/alt/python35/lib/python3.5/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
tLookupError(tencoding_or_labelR((sR/opt/alt/python35/lib/python3.5/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((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/webencodings/__init__.pyt__init__|s	cCsd|jS(Nu
<Encoding %s>(R(R((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/webencodings/__init__.pyt__repr__€s(t__name__t
__module__t__doc__RR(((sR/opt/alt/python35/lib/python3.5/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((sR/opt/alt/python35/lib/python3.5/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 ((sR/opt/alt/python35/lib/python3.5/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"((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/webencodings/__init__.pyR¬scCs4t||ƒ}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((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/webencodings/__init__.pytiter_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((sR/opt/alt/python35/lib/python3.5/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((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/webencodings/__init__.pytiter_encodeösccsOx(|D] }||ƒ}|r|VqqW|ddtƒ}|rK|VndS(NuR/(R2(R RR3R4((sR/opt/alt/python35/lib/python3.5/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"((sR/opt/alt/python35/lib/python3.5/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((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/webencodings/__init__.pyR's
	

			(RRRRtFalseR(((sR/opt/alt/python35/lib/python3.5/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"((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/webencodings/__init__.pyRTs(RRRR'R(((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/webencodings/__init__.pyR5Cs(Rt
__future__RRtlabelsRtVERSIONR
RRRRtobjectRR'R%R&RRRR-R)R7R6R(R5(((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/webencodings/__init__.pyt<module>
s4
					 	
3
Back to Directory File Manager