Team Ai
Datasetpublic

codekingpro/portable-devtools

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

2��ja?��p�SrSSKrSSKrSSKJr SSKrSSKrSSKrSSKrSSKJ	r	J3r4JrJrJ
r
JrJrJrJrJr \R&(aSSKrSSKJr SSKJr SSKr\r\r\r\R<r"SS\\\	45r"S	S55r S\S\	4S
jr!S+S\	S\\\	4S\6\7\\\	4SS4Sjjr"S\\8\#\9\$\10S4S\RJ4Sjr&S\$S\11\'4Sjr(\)"S5r*S\\S\4Sjr+\RX"S\RZ5r.S\S\4Sjr/"SS5r0"SS 5r1S!r2S"\S#\S\4S$jr3\RhRkS%5(d\RhRkS&5S':Xa\3r6OSS(K7J8r6 S*r:g!\9a% \RhRkS&5S):Xae\3r6N.f=f),a�Miscellaneous utility functions and classes.12 13This module is used internally by Tornado.  It is not necessarily expected14that the functions and classes defined here will be useful to other15applications, but they are documented here in case they are.16 17The one public-facing part of this module is the `Configurable` class18and its `~Configurable.configure` method, which becomes a part of the19interface of its subclasses, including `.AsyncHTTPClient`, `.IOLoop`,20and `.Resolver`.21�N)�getfullargspec)22�Any�Optional�Dict�Mapping�List�Tuple�Match�Callable�Type�Sequence)�
TracebackType)�Unionc�@�\rSrSrSrS\S\4SjrS\S\SS4SjrS	r	g)23�24ObjectDict�7zFMakes a dictionary behave like an object, with attribute-style access.�name�returnc�>�X$![a [U5ef=f�N)�KeyError�AttributeError)�selfrs  �RD:\code\apps\devtools\python\user_packages\Python313\site-packages\tornado/util.py�__getattr__�ObjectDict.__getattr__:s)��	'��:����	'� ��&�&�	'�s���valueNc��X U'gr�)rrrs   r�__setattr__�ObjectDict.__setattr__@s	���T�25�r)26�__name__�27__module__�__qualname__�__firstlineno__�__doc__�strrrr �__static_attributes__rr"rrr7s2��P�'��'��'����C��D�r"rc�b�\rSrSrSrSSjrS
S\S\S\4Sjjr\	S\4S	j5r28S\4S29jrSrg)�GzipDecompressor�Dz�Streaming gzip decompressor.30 31The interface is like that of `zlib.decompressobj` (without some of the32optional arguments, but it understands gzip headers and checksums.33rNc�\�[R"S[R-5Ulg)N�)�zlib�
decompressobj�	MAX_WBITS�rs r�__init__�GzipDecompressor.__init__Ks ��"�/�/��T�^�^�0C�D��r"r�34max_lengthc�8�URRX5$)a}Decompress a chunk, returning newly-available data.35 36Some data may be buffered for later processing; `flush` must37be called when there is no more input data to ensure that38all data was processed.39 40If ``max_length`` is given, some input data may be left over41in ``unconsumed_tail``; you must retrieve this value and pass42it back to a future call to `decompress` if it is not empty.43)r0�44decompress)rrr5s   rr7�GzipDecompressor.decompressQs���!�!�,�,�U�?�?r"c�.�URR$)z(Returns the unconsumed portion left over)r0�unconsumed_tailr2s rr:� GzipDecompressor.unconsumed_tail^s���!�!�1�1�1r"c�6�URR5$)z�Return any remaining buffered data not yet returned by decompress.45 46Also checks for errors such as truncated input.47No other methods may be called on this object after `flush`.48)r0�flushr2s rr=�GzipDecompressor.flushcs���!�!�'�'�)�)r")r0�rN)r)
r#r$r%r&r'r3�bytes�intr7�propertyr:r=r)rr"rr+r+DsR���E�@��@�3�@�u�@��2��2��2�*�u�*r"r+rrc��URS5S:Xa[U5$URS5n[SRUSS5US/S9n[	X!S5$![49a [
SUS-5ef=f)a�Imports an object by name.50 51``import_object('x')`` is equivalent to ``import x``.52``import_object('x.y.z')`` is equivalent to ``from x.y import z``.53 54>>> import tornado.escape55>>> import_object('tornado.escape') is tornado.escape56True57>>> import_object('tornado.escape.utf8') is tornado.escape.utf858True59>>> import_object('tornado') is tornado60True61>>> import_object('tornado.missing_module')62Traceback (most recent call last):63    ...64ImportError: No module named missing_module65�.rN�����)�fromlistzNo module named %s)�count�66__import__�split�join�getattrr�ImportError)r�parts�objs   r�
import_objectrOls���$�z�z�#��!���$����J�J�s�O�E�67�S�X�X�e�C�R�j�)�U�2�Y�K�68@�C�<��s�"�I�&�&���<��.��r��:�;�;�<�s�
A!�!A=�code�glob�locc�^�[U[5(a[USSSS9n[XU5 g)Nz<string>�execT)�dont_inherit)�69isinstancer(�compilerT)rPrQrRs   r�exec_inrX�s-���$�����t�Z��d�C����S�r"�exc_inforc�b�USbUSRUS5e[S5e!Snf=f)N��z'raise_exc_info called with no exception)NNN)�with_traceback�	TypeError)rYs r�raise_exc_infor_�s?��&��A�;�"��1�+�,�,�X�a�[�9�9��E�F�F��&��s�(*�.�ec�~�[US5(aUR$UR(aURS$g)a4Provides the errno from an Exception object.70 71There are cases that the errno attribute was not set so we pull72the errno out of the args but if someone instantiates an Exception73without any args you will get a tuple error. So this function74abstracts all that behavior to give you a safe way to get the75errno.76�errnorN)�hasattrrb�args)r`s r�errno_from_exceptionre�s2���q�'����w�w��	77����v�v�a�y��r"�>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789�matchc�d�URS5nUS[;a[SUS-5eU$)Nr[rzcannot unescape '\\%s')�group�	_alphanum�78ValueError)rgris  r�_re_unescape_replacementrl�s5���K�K��N�E��Q�x�9���3�e�A�h�>�?�?��Lr"z\\(.)�sc�6�[R[U5$)z�Unescape a string escaped by `re.escape`.79 80May raise ``ValueError`` for regular expressions which could not81have been produced by `re.escape` (for example, strings containing82``\d`` cannot be unescaped).83 84.. versionadded:: 4.485)�_re_unescape_pattern�subrl)rms r�re_unescaperq�s�� �#�#�$<�a�@�@r"c�^�\rSrSrSrSrSrS\S\S\4U4Sjjr\	S5r86\	S	5rSS87jr\r
\	S5r\	S5r\	S
5r\	S5rSrU=r$)�Configurable��a�Base class for configurable interfaces.88 89A configurable interface is an (abstract) class whose constructor90acts as a factory function for one of its implementation subclasses.91The implementation subclass as well as optional keyword arguments to92its initializer can be set globally at runtime with `configure`.93 94By using the constructor as the factory method, the interface95looks like a normal class, `isinstance` works as usual, etc.  This96pattern is most useful when the choice of implementation is likely97to be a global decision (e.g. when `~select.epoll` is available,98always use it instead of `~select.select`), or when a99previously-monolithic class has been split into specialized100subclasses.101 102Configurable subclasses must define the class methods103`configurable_base` and `configurable_default`, and use the instance104method `initialize` instead of ``__init__``.105 106.. versionchanged:: 5.0107 108   It is now possible for configuration to be specified at109   multiple levels of a class hierarchy.110 111Nrd�kwargsrc�L>�UR5n0nXLa=UR5nUR(aURUR5 OUnURU5 UR5ULaU"U0UD6$[TU]U5nUR"U0UD6 U$r)�configurable_base�configured_class�_Configurable__impl_kwargs�update�super�__new__�112initialize)�clsrdru�base�init_kwargs�impl�instance�	__class__s       �rr|�Configurable.__new__�s�����$�$�&�����;��'�'�)�D��!�!��"�"�4�#5�#5�6���D����6�"��!�!�#�4�/���-��-�-��7�?�4�(��	���T�1�[�1��r"c��[5e)z�Returns the base class of a configurable hierarchy.113 114This will normally return the class in which it is defined.115(which is *not* necessarily the same as the ``cls`` classmethod116parameter).117 118��NotImplementedError�r~s rrw�Configurable.configurable_bases
��"�#�#r"c��[5e)zBReturns the implementation class to be used if none is configured.r�r�s r�configurable_default�!Configurable.configurable_defaults
��"�#�#r"c��grrr2s r�_initialize�Configurable._initializes��r"c���UR5n[U[5(a+[R"[119[[U55nUb[X5(d[SU-5eXl120X#lg)z�Sets the class to use when the base class is instantiated.121 122Keyword arguments will be saved and added to the arguments passed123to the constructor.  This can be used to set global defaults for124some parameters.125NzInvalid subclass of %s)rwrVr(�typing�castrrsrO�126issubclassrk�_Configurable__impl_classry)r~r�rurs    r�	configure�Configurable.configure$sf���$�$�&���d�C� � ��;�;�t�L�1�=��3F�G�D���J�t�$9�$9��5��;�<�<� ��#�r"c���UR5nURRS5cUR5UlURbUR$[S5e)z'Returns the currently configured class.r�zconfigured class not found)rw�__dict__�getr�r�rk�r~rs  rrx�Configurable.configured_class5sa���$�$�&���=�=���8�9�A� #� 8� 8� :�D�����(��$�$�$��9�:�:r"c�R�UR5nURUR4$r�rwr�ryr�s  r�_save_configuration� Configurable._save_configurationEs)���$�$�&���!�!�4�#5�#5�6�6r"c�L�UR5nUSUlUSUlg)Nrr[r�)r~�savedrs   r�_restore_configuration�#Configurable._restore_configurationKs*���$�$�&��!�!�H���"�1�X��r"rr?)r#r$r%r&r'r�ryrr|�classmethodrwr�r�r}r�rxr�r�r)�
__classcell__)r�s@rrsrs�s�����D�L��M��C��3��3��(�	$��	$��$��$�127
��J���$��$� �
;��
;��7��7�128�&��&r"rsc
��\rSrSrSrS\S\SS4SjrS\S\\4Sjr	SS	\129\S130\\\4S\S\4Sjjr
S
\S	\131\S132\\\4S\\\133\\\\444SjrSrg)�ArgReplaceriSz�Replaces one value in an ``args, kwargs`` pair.134 135Inspects the function signature to find an argument by name136whether it is passed by position or keyword.  For use in decorators137and similar wrappers.138�funcrrNc��X lURU5RU5Ulg![a139 SUlgf=fr)r�_getargnames�index�arg_posrk)rr�rs   rr3�ArgReplacer.__init__[s?���	�	 ��,�,�T�2�8�8��>�D�L���	 ��D�L�	 �s�%.�A�Ac��[U5R$![a: [US5(a'URnUR140SURs$ef=f)N�	func_code)rrdr^rcr��co_varnames�co_argcount)rr�rPs   rr��ArgReplacer._getargnamescs\��	�!�$�'�,�,�,���141	��t�[�)�)��~�~���'�'�(:�$�*:�*:�;�;��142	�s��AA�Ardru�defaultc��URb'[U5UR:�aXR$URURU5$)zwReturns the old value of the named argument without replacing it.143 144Returns ``default`` if the argument is not present.145)r��lenr�r)rrdrur�s    r�
get_old_value�ArgReplacer.get_old_valuers?���<�<�#��D�	�D�L�L�(@����%�%��:�:�d�i�i��1�1r"�	new_valuec���URbA[U5UR:�a(X Rn[U5nXUR'O)URUR5nXUR'XBU4$)adReplace the named argument in ``args, kwargs`` with ``new_value``.146 147Returns ``(old_value, args, kwargs)``.  The returned ``args`` and148``kwargs`` objects may not be the same as the input objects, or149the input objects may be mutated.150 151If the named argument was not found, ``new_value`` will be added152to ``kwargs`` and None will be returned as ``old_value``.153)r�r��listr�r)rr�rdru�	old_values     r�replace�ArgReplacer.replace~si���<�<�#��D�	�D�L�L�(@��\�\�*�I���:�D�!*������154�155�4�9�9�-�I� )�4�9�9����&�&r")r�rr)r#r$r%r&r'rr(r3rr�r
rrr�r	r�r)rr"rr�r�Ss���� �X� �S� �T� �
��
�d�3�i�
� KO�1562��S�M�1572�+/��S��>�1582�DG�1592�	�1602�'��'�$,�S�M�'�;?��S��>�'�	�s�H�S�M�4��S��>�1�	2�'r"r�c�"�UR5$)z@Equivalent to ``td.total_seconds()`` (introduced in Python 2.7).)�
total_seconds)�tds r�timedelta_to_secondsr��s������r"�mask�datac���[R"SU5n[R"SU5n[[U55HnX4X$S--X4'M UR5$)a=Websocket masking function.161 162`mask` is a `bytes` object of length 4; `data` is a `bytes` object of any length.163Returns a `bytes` object of the same length as `data` with the mask applied164as specified in section 5.3 of RFC 6455.165 166This pure-python implementation may be replaced by an optimized version when available.167�B�)�array�ranger��tobytes)r�r��mask_arr�unmasked_arr�is     r�_websocket_mask_pythonr��sZ���{�{�3��%�H��;�;�s�D�)�L�
�3�t�9�
��&�/�H��U�O�;�������!�!r"�TORNADO_NO_EXTENSION�TORNADO_EXTENSION�0)�websocket_mask�1c�*�SSKnUR5$)Nr)�doctest�DocTestSuite)r�s r�doctestsr��s������!�!r"r);r'r��asyncio�inspectr�os�rer�r/rrrrrr	r168rrr
�
TYPE_CHECKING�datetime�typesrr�unittestr@�169bytes_typer(�unicode_type�basestring_type�TimeoutErrorrr+rOrX�type�
BaseException�NoReturnr_rAre�	frozensetrjrlrW�DOTALLrorqrsr�r�r��environr��_websocket_mask�tornado.speedupsr�rLr�rr"r�<module>r�s#��170�
��"�	�	�
�����171����#���172�173�����174�#�#��175��c�3�h��176�%*�%*�P<��<��<�<SW��177
���#�s�(�^��*2�8�G�C��H�<M�3N�*O��	��&��H�T�N�H�]�$;�X�o�=V�V�W�&��_�_�&��M��h�s�m��$
�V�W�	��E�#�J��3���z�z�(�B�I�I�6��	A�3�	A�3�	A�D&�D&�N@'�@'�F�
"��
"�e�
"��
"� �:�:�>�>�(�)�)�R�Z�Z�^�^�<O�-P�TW�-W�-�O�1�F�"��
�1�
�:�:�>�>�-�.�#�5��0��1�s�F178�179(F5�4F5
codekingpro/portable-devtools · Team Ai