%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib64/python2.7/site-packages/tornado/
Upload File :
Create Path :
Current File : //usr/lib64/python2.7/site-packages/tornado/escape.pyc

�
��L]c@�s�dZddlmZmZmZmZddlZddlZddlm	Z	m
Z
mZyddlm
ZWn!ek
r�ddlm
ZnXyddlZWn ek
r�ddljZnXyddljZWnek
r�ddlZnXddlZyeWnek
r'eZnXejd�Zidd6d	d
6dd6d
d6dd6Zd�Zd�Zd�Z d�Z!d�Z"e#d�Z$ej%ddkr�de#d�Z&eZ'nde#d�Z&e(e(d�Z'e)e*d�fZ,d�Z-e	e*d�fZ.d�Z/e/Z0e1e	kr3e/Z2ne-Z2e
e*d�fZ3d�Z4d�Z5eje/d ��Z6e(d!e(d"d#gd$�Z7d%�Z8d&�Z9e9�Z:dS('s�Escaping/unescaping methods for HTML, JSON, URLs, and others.

Also includes a few other miscellaneous string manipulation functions that
have crept in over time.
i(tabsolute_importtdivisiontprint_functiontwith_statementN(tunicode_typetbasestring_typetu(tparse_qss[&<>"']s&amp;t&s&lt;t<s&gt;t>s&quot;t"s&#39;s'cC�stjd�t|��S(s0Escapes a string so it is valid within HTML or XML.

    Escapes the characters ``<``, ``>``, ``"``, ``'``, and ``&``.
    When used in attribute values the escaped strings must be enclosed
    in quotes.

    .. versionchanged:: 3.2

       Added the single quote to the list of escaped characters.
    cS�st|jd�S(Ni(t_XHTML_ESCAPE_DICTtgroup(tmatch((s4/usr/lib64/python2.7/site-packages/tornado/escape.pyt<lambda>Cs(t_XHTML_ESCAPE_REtsubt
to_basestring(tvalue((s4/usr/lib64/python2.7/site-packages/tornado/escape.pytxhtml_escape8scC�stjdtt|��S(s!Un-escapes an XML-escaped string.s&(#?)(\w+?);(treRt_convert_entityt_unicode(R((s4/usr/lib64/python2.7/site-packages/tornado/escape.pytxhtml_unescapeGscC�stj|�jdd�S(s%JSON-encodes the given Python object.s</s<\/(tjsontdumpstreplace(R((s4/usr/lib64/python2.7/site-packages/tornado/escape.pytjson_encodeOscC�stjt|��S(s1Returns Python objects for the given JSON string.(RtloadsR(R((s4/usr/lib64/python2.7/site-packages/tornado/escape.pytjson_decodeZscC�stjdd|�j�S(s>Replace all sequences of whitespace chars with a single space.s[\x00-\x20]+t (RRtstrip(R((s4/usr/lib64/python2.7/site-packages/tornado/escape.pytsqueeze_scC�s(|rtjntj}|t|��S(siReturns a URL-encoded version of the given value.

    If ``plus`` is true (the default), spaces will be represented
    as "+" instead of "%20".  This is appropriate for query strings
    but not for the path component of a URL.  Note that this default
    is the reverse of Python's urllib module.

    .. versionadded:: 3.1
        The ``plus`` argument
    (turllib_parset
quote_plustquotetutf8(RtplusR$((s4/usr/lib64/python2.7/site-packages/tornado/escape.pyt
url_escapedsisutf-8cC�sQ|rtjntj}|dkr4|t|��St|t|��|�SdS(s�Decodes the given value from a URL.

        The argument may be either a byte or unicode string.

        If encoding is None, the result will be a byte string.  Otherwise,
        the result is a unicode string in the specified encoding.

        If ``plus`` is true (the default), plus signs will be interpreted
        as spaces (literal plus signs must be represented as "%2B").  This
        is appropriate for query strings and form-encoded values but not
        for the path component of a URL.  Note that this default is the
        reverse of Python's urllib module.

        .. versionadded:: 3.1
           The ``plus`` argument
        N(R"tunquote_plustunquotetNoneR%R(RtencodingR&R)((s4/usr/lib64/python2.7/site-packages/tornado/escape.pyturl_unescapewscC�sl|dkr:|r-t|�jdd�}ntj|�S|rItjntj}|t|�d|�SdS(s�Decodes the given value from a URL.

        The argument may be either a byte or unicode string.

        If encoding is None, the result will be a byte string.  Otherwise,
        the result is a unicode string in the specified encoding.

        If ``plus`` is true (the default), plus signs will be interpreted
        as spaces (literal plus signs must be represented as "%2B").  This
        is appropriate for query strings and form-encoded values but not
        for the path component of a URL.  Note that this default is the
        reverse of Python's urllib module.

        .. versionadded:: 3.1
           The ``plus`` argument
        t+RR+N(R*RRR"tunquote_to_bytesR(R)(RR+R&R)((s4/usr/lib64/python2.7/site-packages/tornado/escape.pyR,�s
	cC�skt|||dddd�}i}x@|j�D]2\}}g|D]}|jd�^qD||<q1W|S(s3Parses a query string like urlparse.parse_qs, but returns the
        values as byte strings.

        Keys still become type str (interpreted as latin1 in python3!)
        because it's too painful to keep them as byte strings in
        python3 and in practice they're nearly always ascii anyway.
        R+tlatin1terrorststrict(t	_parse_qstitemstencode(tqstkeep_blank_valueststrict_parsingtresulttencodedtktvti((s4/usr/lib64/python2.7/site-packages/tornado/escape.pytparse_qs_bytes�s
*cC�sHt|t�r|St|t�s;tdt|���n|jd�S(s�Converts a string argument to a byte string.

    If the argument is already a byte string or None, it is returned unchanged.
    Otherwise it must be a unicode string and is encoded as utf8.
    s(Expected bytes, unicode, or None; got %rsutf-8(t
isinstancet_UTF8_TYPESRt	TypeErrorttypeR4(R((s4/usr/lib64/python2.7/site-packages/tornado/escape.pyR%�scC�sHt|t�r|St|t�s;tdt|���n|jd�S(s�Converts a string argument to a unicode string.

    If the argument is already a unicode string or None, it is returned
    unchanged.  Otherwise it must be a byte string and is decoded as utf8.
    s(Expected bytes, unicode, or None; got %rsutf-8(R>t_TO_UNICODE_TYPEStbytesR@RAtdecode(R((s4/usr/lib64/python2.7/site-packages/tornado/escape.pyt
to_unicode�scC�sHt|t�r|St|t�s;tdt|���n|jd�S(s�Converts a string argument to a subclass of basestring.

    In python2, byte and unicode strings are mostly interchangeable,
    so functions that deal with a user-supplied argument in combination
    with ascii string constants can use either and should return the type
    the user supplied.  In python3, the two types are not interchangeable,
    so this method is needed to convert byte strings to unicode.
    s(Expected bytes, unicode, or None; got %rsutf-8(R>t_BASESTRING_TYPESRCR@RARD(R((s4/usr/lib64/python2.7/site-packages/tornado/escape.pyR�s	cC�s�t|t�r)td�|j�D��St|t�rLtd�|D��St|t�rotd�|D��St|t�r�t|�S|SdS(svWalks a simple data structure, converting byte strings to unicode.

    Supports lists, tuples, and dictionaries.
    cs�s-|]#\}}t|�t|�fVqdS(N(trecursive_unicode(t.0R:R;((s4/usr/lib64/python2.7/site-packages/tornado/escape.pys	<genexpr>scs�s|]}t|�VqdS(N(RG(RHR<((s4/usr/lib64/python2.7/site-packages/tornado/escape.pys	<genexpr>scs�s|]}t|�VqdS(N(RG(RHR<((s4/usr/lib64/python2.7/site-packages/tornado/escape.pys	<genexpr>	sN(R>tdictR3tlistttupleRCRE(tobj((s4/usr/lib64/python2.7/site-packages/tornado/escape.pyRG�s
s�\b((?:([\w-]+):(/{1,3})|www[.])(?:(?:(?:[^\s&()]|&amp;|&quot;)*(?:[^!"#$%&'()*+,.:;<=>?@\[\]^`{|}~\s]))|(?:\((?:[^\s&()]|&amp;|&quot;)*\)))+)tthttpthttpsc�s`�r&t��r&d�j��n����fd�}tt|��}tj||�S(s�Converts plain text into HTML with links.

    For example: ``linkify("Hello http://tornadoweb.org!")`` would return
    ``Hello <a href="http://tornadoweb.org">http://tornadoweb.org</a>!``

    Parameters:

    * ``shorten``: Long urls will be shortened for display.

    * ``extra_params``: Extra text to include in the link tag, or a callable
        taking the link as an argument and returning the extra text
        e.g. ``linkify(text, extra_params='rel="nofollow" class="external"')``,
        or::

            def extra_params_cb(url):
                if url.startswith("http://example.com"):
                    return 'class="internal"'
                else:
                    return 'class="external" rel="nofollow"'
            linkify(text, extra_params=extra_params_cb)

    * ``require_protocol``: Only linkify urls which include a protocol. If
        this is False, urls such as www.facebook.com will also be linkified.

    * ``permitted_protocols``: List (or set) of protocols which should be
        linkified, e.g. ``linkify(text, permitted_protocols=["http", "ftp",
        "mailto"])``. It is very unsafe to include protocols such as
        ``javascript``.
    Rc
�s|jd�}|jd�}�r/|r/|S|rE|�krE|S|jd�}|sgd|}nt��r�d�|�j�}n�}d}�r�t|�|kr�|}|r�t|�dt|jd�p�d�}nd}||jd	�}t|�dkrR|| |dd	|dd
 jd�djd�d}nt|�|d
kru|| }n||kr�|jd�}	|	|dkr�||	 }n|d7}t|�t|�kr�|}q�|d|7}q�ntd�|||fS(Niishttp://RiiRMit/it?t.g�?Ris...s title="%s"s<a href="%s"%s>%s</a>(R
tcallableR tlentsplittrfindR(
tmturltprotothreftparamstmax_lentbefore_clipt	proto_lentpartstamp(textra_paramstpermitted_protocolstrequire_protocoltshorten(s4/usr/lib64/python2.7/site-packages/tornado/escape.pyt	make_link;sB

,,


	(RSR RRt_URL_RER(ttextRdRaRcRbRe((RaRbRcRds4/usr/lib64/python2.7/site-packages/tornado/escape.pytlinkifys
:cC�s�|jd�dkr�y\|jd�d j�dkrWtt|jd�dd��Stt|jd���SWq�tk
r�d|jd�SXnyt|jd�SWntk
r�d|jd�SXdS(Nit#itxis&#%s;s&%s;(R
tlowertunichrtintt
ValueErrort_HTML_UNICODE_MAPtKeyError(RW((s4/usr/lib64/python2.7/site-packages/tornado/escape.pyRys 

cC�s:i}x-tjj�D]\}}t|�||<qW|S(N(thtmlentitydefstname2codepointR3Rl(tunicode_maptnameR((s4/usr/lib64/python2.7/site-packages/tornado/escape.pyt_build_unicode_map�s(;t__doc__t
__future__RRRRRtsysttornado.utilRRRturllib.parseRR2tImportErrorturlparseRqt
html.entitiestentitiestparseR"turllibRRlt	NameErrortchrtcompileRRRRRRR!tTrueR'tversion_infoR,R=tFalseRCRAR*R?R%RBRERtstrt
native_strRFRRGRfRhRRuRo(((s4/usr/lib64/python2.7/site-packages/tornado/escape.pyt<module>sh"





											_		

Zerion Mini Shell 1.0