Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
escape.cpython-313.pyc173 linesDownload Raw Back to __pycache__
1�

2��j9�
� �SrSSKrSSKrSSKrSSKrSSKJr SSKrSSKJ	r	J3r4JrJrJ
r
Jr S\	\\4S\4SjrS\	\\4S\4SjrS\5S\4S	jrS\	\\4S\64S7jrS\S\4SjrS+S\	\\4S\S\4S
jjr\R0S+S\	\\4SSS\S\4Sjj5r\R0S,S\	\\4S\S\S\4Sjj5rS,S\	\\4S\\S\S\	\\44SjjrS-S\	\\4S\S\S\\\
\44Sjjr\\"S54r\R0S\S\4Sj5r\R0S\S\4Sj5r\R0S.Sj5rS\	S\\4S\\4Sjr\\"S54r\R0S\S\4Sj5r\R0S\S\4Sj5r\R0S.Sj5rS\	S\\4S\\4Sjr\r \r!\r"S\8S\94S jr#\RH"\"S!55r%SS"SS#S$/4S%\	\\4S&\S'\	\\\/\44S(\S)\
\S\4S*jjr&g)/a�Escaping/unescaping methods for HTML, JSON, URLs, and others.10 11Also includes a few other miscellaneous string manipulation functions that12have crept in over time.13 14Many functions in this module have near-equivalents in the standard library15(the differences mainly relate to handling of bytes and unicode strings,16and were more relevant in Python 2). In new code, the standard library17functions are encouraged instead of this module where applicable. See the18docstrings on each function for details.19�N)�unicode_type)�Union�Any�Optional�Dict�List�Callable�value�returnc�@�[R"[U55$)aEscapes a string so it is valid within HTML or XML.20 21Escapes the characters ``<``, ``>``, ``"``, ``'``, and ``&``.22When used in attribute values the escaped strings must be enclosed23in quotes.24 25Equivalent to `html.escape` except that this function always returns26type `str` while `html.escape` returns `bytes` if its input is `bytes`.27 28.. versionchanged:: 3.229 30   Added the single quote to the list of escaped characters.31 32.. versionchanged:: 6.433 34   Now simply wraps `html.escape`. This is equivalent to the old behavior35   except that single quotes are now escaped as ``&#x27;`` instead of36   ``&#39;`` and performance may be different.37)�html�escape�38to_unicode�r39s �TD:\code\apps\devtools\python\user_packages\Python313\site-packages\tornado/escape.py�xhtml_escaper's��(�;�;�z�%�(�)�)�c�@�[R"[U55$)a6Un-escapes an XML-escaped string.40 41Equivalent to `html.unescape` except that this function always returns42type `str` while `html.unescape` returns `bytes` if its input is `bytes`.43 44.. versionchanged:: 6.445 46   Now simply wraps `html.unescape`. This changes behavior for some inputs47   as required by the HTML 5 specification48   https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-end-state49 50   Some invalid inputs such as surrogates now raise an error, and numeric51   references to certain ISO-8859-1 characters are now handled correctly.52)r
�unescaperrs r�xhtml_unescaper>s���=�=��E�*�+�+rc�N�[R"U5RSS5$)z�JSON-encodes the given Python object.53 54Equivalent to `json.dumps` with the additional guarantee that the output55will never contain the character sequence ``</`` which can be problematic56when JSON is embedded in an HTML ``<script>`` tag.57z</z<\/)�json�dumps�replacers r�json_encoderSs ���:�:�e��$�$�T�6�2�2rc�.�[R"U5$)zvReturns Python objects for the given JSON string.58 59Supports both `str` and `bytes` inputs. Equvalent to `json.loads`.60)r�loadsrs r�json_decodercs��61�:�:�e��rc�N�[R"SSU5R5$)z>Replace all sequences of whitespace chars with a single space.z[\x00-\x20]+� )�re�sub�striprs r�squeezer$ks��
�6�6�/�3��.�4�4�6�6r�plusc��U(a[RRO[RRnU"U5$)aUReturns a URL-encoded version of the given value.62 63Equivalent to either `urllib.parse.quote_plus` or `urllib.parse.quote` depending on the ``plus``64argument.65 66If ``plus`` is true (the default), spaces will be represented as ``+`` and slashes will be67represented as ``%2F``.  This is appropriate for query strings. If ``plus`` is false, spaces68will be represented as ``%20`` and slashes are left as-is. This is appropriate for the path69component of a URL. Note that the default of ``plus=True`` is effectively the70reverse of Python's urllib module.71 72.. versionadded:: 3.173    The ``plus`` argument74)�urllib�parse�75quote_plus�quote)r76r%r*s   r�77url_escaper+ps+��(,�F�L�L�#�#����1C�1C�E���<�r�encodingc��g�N��r78r,r%s   r�url_unescaper1����rc��gr.r/r0s   rr1r1�s��	rc� �UcAU(a[U5RSS5n[RR	U5$U(a[RR79O[RRnU"[U5US9$)aDecodes the given value from a URL.80 81The argument may be either a byte or unicode string.82 83If encoding is None, the result will be a byte string and this function is equivalent to84`urllib.parse.unquote_to_bytes` if ``plus=False``.  Otherwise, the result is a unicode string in85the specified encoding and this function is equivalent to either `urllib.parse.unquote_plus` or86`urllib.parse.unquote` except that this function also accepts `bytes` as input.87 88If ``plus`` is true (the default), plus signs will be interpreted as spaces (literal plus signs89must be represented as "%2B").  This is appropriate for query strings and form-encoded values90but not for the path component of a URL.  Note that this default is the reverse of Python's91urllib module.92 93.. versionadded:: 3.194   The ``plus`` argument95�+r )r,)�
to_basestringrr'r(�unquote_to_bytes�unquote_plus�unquote)r96r,r%r9s    rr1r1�sh��(���!�%�(�0�0��c�:�E��|�|�,�,�U�3�3�/3�&�,�,�+�+����9M�9M���}�U�+�h�?�?rF�qs�keep_blank_values�strict_parsingc��[U[5(aURS5n[RRXUSSS9n0nUR
5H(upVUVs/sHowRS5PM snXE'M* U$s snf)aParses a query string like urlparse.parse_qs,97but takes bytes and returns the values as byte strings.98 99Keys still become type str (interpreted as latin1 in python3!)100because it's too painful to keep them as byte strings in101python3 and in practice they're nearly always ascii anyway.102�latin1�strict)r,�errors)�103isinstance�bytes�decoder'r(�parse_qs�items�encode)r:r;r<�result�encoded�k�v�is        r�parse_qs_bytesrL�s����"�e���
�Y�Y�x�
 ��
�\�\�
"�
"�104�~���#��F��G�������23�4�!�Q�h�h�x�(�!�4��105���N��5s�"Bc��gr.r/rs r�utf8rN�r2rc��gr.r/rs rrNrN�r2rc��gr.r/rs rrNrN�r2rc��[U[5(aU$[U[5(d[S[	U5-5eURS5$)z�Converts a string argument to a byte string.106 107If the argument is already a byte string or None, it is returned unchanged.108Otherwise it must be a unicode string and is encoded as utf8.109�(Expected bytes, unicode, or None; got %r�utf-8)rA�_UTF8_TYPESr�	TypeError�typerFrs rrNrN�sG���%��%�%����e�\�*�*��B�T�%�[�P�Q�Q��<�<�� � rc��gr.r/rs rrr�r2rc��gr.r/rs rrr�r2rc��gr.r/rs rrr�r2rc��[U[5(aU$[U[5(d[S[	U5-5eURS5$)z�Converts a string argument to a unicode string.110 111If the argument is already a unicode string or None, it is returned112unchanged.  Otherwise it must be a byte string and is decoded as utf8.113rRrS)rA�_TO_UNICODE_TYPESrBrUrVrCrs rrr�sH���%�*�+�+����e�U�#�#��B�T�%�[�P�Q�Q��<�<�� � r�objc��[U[5(a8UR5VVs0sHup[U5[U5_M snn$[U[5(a[	SU55$[U[1145(a[SU55$[U[5(a[U5$U$s snnf)znWalks a simple data structure, converting byte strings to unicode.115 116Supports lists, tuples, and dictionaries.117c3�8# �UHn[U5v� M g7fr.��recursive_unicode��.0rKs  r�	<genexpr>�$recursive_unicode.<locals>.<genexpr>s���6�#�Q�%�a�(�(�#���c3�8# �UHn[U5v� M g7fr.r_ras  rrcrds���7�3�a�&�q�)�)�3�re)rA�dictrEr`�list�tuplerBr)r\rIrJs   rr`r`s���118�#�t���IL����U��v��!�!�$�&7��&:�:��U�U�	�C��	�	��6�#�6�6�6�	�C��	�	��7�3�7�7�7�	�C��	�	��#����119��Vs�!B>z�\b((?:([\w-]+):(/{1,3})|www[.])(?:(?:(?:[^\s&()]|&amp;|&quot;)*(?:[^!"#$%&'()*+,.:;<=>?@\[\]^`{|}~\s]))|(?:\((?:[^\s&()]|&amp;|&quot;)*\)))+)��http�https�text�shorten�extra_params�require_protocol�permitted_protocolsc��^^^^�T(a#[T5(dSTR5-mS[RS[4UUUU4Sjjn[[
U55n[RXP5$)a7Converts plain text into HTML with links.120 121For example: ``linkify("Hello http://tornadoweb.org!")`` would return122``Hello <a href="http://tornadoweb.org">http://tornadoweb.org</a>!``123 124Parameters:125 126* ``shorten``: Long urls will be shortened for display.127 128* ``extra_params``: Extra text to include in the link tag, or a callable129  taking the link as an argument and returning the extra text130  e.g. ``linkify(text, extra_params='rel="nofollow" class="external"')``,131  or::132 133      def extra_params_cb(url):134          if url.startswith("http://example.com"):135              return 'class="internal"'136          else:137              return 'class="external" rel="nofollow"'138      linkify(text, extra_params=extra_params_cb)139 140* ``require_protocol``: Only linkify urls which include a protocol. If141  this is False, urls such as www.facebook.com will also be linkified.142 143* ``permitted_protocols``: List (or set) of protocols which should be144  linkified, e.g. ``linkify(text, permitted_protocols=["http", "ftp",145  "mailto"])``. It is very unsafe to include protocols such as146  ``javascript``.147r �mrc�\>�URS5nURS5nT(a	U(dU$U(aUT;aU$URS5nU(dSU-n[T1485(aST149"U5R5-nOT150nSnT
(Ga[U5U:�a�UnU(a3[U5S-[URS5=(d S5-nOSnXSR	S	5n[U5S:�a;USUUS-S	-USSS151R	S5SR	S5S-n[U5US
-:�aUSUnX:waFURS5n	X�S-152:�aUSU	nUS-
n[U5[U5:�aUnOUSU--
nSUSUSUS3$)N��zhttp://r ��rjr�/��?�.g�?�&�z...z title="%s"z	<a href="�"�>z</a>)�group�callabler#�len�split�rfind)rs�url�proto�href�params�max_len�before_clip�	proto_len�parts�amprorqrprns          ����r�	make_link�linkify.<locals>.make_linkRs�����g�g�a�j������153���E��J��U�"5�5��J��w�w�q�z����t�#�D��L�!�!��<��-�3�3�5�5�F�!�F����s�3�x�'�)��K����J��N�S������1A�r�-B�B�	��	��154�O�)�)�#�.�E��5�z�A�~��155��O��A�h�����A�h�r��l�(�(��-�a�0�6�6�s�;�A�>�?���3�x�'�C�-�'��(�7�m���!��i�i��n���1��$��d�s�)�C��u����s�8�s�;�/�/�%�C��m�d�2�2�F��4�&��&���3�%�t�4�4r)	r�r#�typing�Match�str�_unicoder�_URL_REr")rmrnrorprqr�s ```` r�linkifyr�+sc���H�H�\�2�2��\�/�/�1�1��95�V�\�\�95�c�95�95�|�L��&�'�D��;�;�y�'�'r)T)rST)FF)r156NrN)'�__doc__r
rr!�urllib.parser'�tornado.utilrr�rrrrrr	r�rBrrrrr$�boolr+�overloadr1rLrVrTrNr[rr��157native_strr6r`�compiler�r�r/rr�<module>r�s��� 158���	��%�
�=�=�*��c�5�j�)�*�c�*�.,�%��U�159�+�,��,�*
3�s�
3�s�
3� �u�S�%�Z�(��S��7�3�7�3�7�160�e�C��J�'��t��s��&���	��c�5�j�)�	�T�	��	�QV�	��	����DH�	���e���	�(+�	�=A�	��	��	�OS�@���e���@�(0��
�@�GK�@�161�3��:��@�>TY��
�c�5�j���.2��LP��	�#�t�E�{�162���.�d�4�j�!�����	��	�%�	��	����	��	��	��	����	��	�163!��d�C��&�'�164!�H�U�O�165!�"�4��:�.�����	�c�	�c�	��	����	�e�	��	��	����	��	�166!�e�D�#�u�,�-�167!�(�3�-�168!����169��
��3��3��0
�*�*��	]�����57�"�&,�g�%6�f(�170��U�171�172�f(�
�f(���X�s�e�S�j�1�1�2�f(��	f(�173�c��f(�	�
f(r
codekingpro/portable-devtools · Team Ai