Ë
    êmxi¤=  ã                   óR  — d Z ddlZddlZddlmZ ddlZddlZddlZddlZddlm	Z	m
Z
mZmZmZmZmZmZmZmZ ej&                  rddlZddlmZ ddlmZ ddlZeZeZeZej<                  Z G d„ deee	f   «      Z G d	„ d
«      Z dede	fd„Z!	 d+de	deee	f   de
e
eee	f         ddfd„Z"dee
e#   e
e$   e
d   f   dejJ                  fd„Z&de$de
e'   fd„Z( e)d«      Z*dee   defd„Z+ ejX                  dejZ                  «      Z.dedefd„Z/ G d„ d«      Z0 G d„ d «      Z1d!„ Z2d"ed#edefd$„Z3ejh                  jk                  d%«      sejh                  jk                  d&«      d'k(  re3Z6d*„ Z:y	 dd(l7m8Z6 d*„ Z:y# e9$ r' ejh                  jk                  d&«      d)k(  r‚ e3Z6Y d*„ Z:yw xY w),aÞ  Miscellaneous utility functions and classes.

This module is used internally by Tornado.  It is not necessarily expected
that the functions and classes defined here will be useful to other
applications, but they are documented here in case they are.

The one public-facing part of this module is the `Configurable` class
and its `~Configurable.configure` method, which becomes a part of the
interface of its subclasses, including `.AsyncHTTPClient`, `.IOLoop`,
and `.Resolver`.
é    N)Úgetfullargspec)
ÚAnyÚOptionalÚDictÚMappingÚListÚTupleÚMatchÚCallableÚTypeÚSequence)ÚTracebackType)ÚUnionc                   ó4   — e Zd ZdZdedefd„Zdededdfd„Zy)Ú
ObjectDictzFMakes a dictionary behave like an object, with attribute-style access.ÚnameÚreturnc                 ó>   — 	 | |   S # t         $ r t        |«      ‚w xY w©N)ÚKeyErrorÚAttributeError)Úselfr   s     úC/home/htdocs/ttos/venv/lib/python3.12/site-packages/tornado/util.pyÚ__getattr__zObjectDict.__getattr__:   s+   € ð	'Ø˜‘:ÐøÜò 	'Ü  Ó&Ð&ð	'ús   ‚ ‡ÚvalueNc                 ó   — || |<   y r   © )r   r   r   s      r   Ú__setattr__zObjectDict.__setattr__@   s   € ØˆˆTŠ
ó    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústrr   r   r   r   r   r   r   r   7   s2   „ ÙPð' ð '¨ó 'ð ð ¨Cð °Dô r   r   c                   óP   — e Zd ZdZd
d„Zddededefd„Zedefd„«       Z	defd	„Z
y)ÚGzipDecompressorzµStreaming gzip decompressor.

    The interface is like that of `zlib.decompressobj` (without some of the
    optional arguments, but it understands gzip headers and checksums.
    r   Nc                 óZ   — t        j                  dt         j                  z   «      | _        y )Né   )ÚzlibÚdecompressobjÚ	MAX_WBITS©r   s    r   Ú__init__zGzipDecompressor.__init__K   s    € ô "×/Ñ/°´T·^±^Ñ0CÓDˆÕr   r   Ú
max_lengthc                 ó:   — | j                   j                  ||«      S )aµ  Decompress a chunk, returning newly-available data.

        Some data may be buffered for later processing; `flush` must
        be called when there is no more input data to ensure that
        all data was processed.

        If ``max_length`` is given, some input data may be left over
        in ``unconsumed_tail``; you must retrieve this value and pass
        it back to a future call to `decompress` if it is not empty.
        )r*   Ú
decompress)r   r   r.   s      r   r0   zGzipDecompressor.decompressQ   s   € ð ×!Ñ!×,Ñ,¨U°JÓ?Ð?r   c                 ó.   — | j                   j                  S )z(Returns the unconsumed portion left over)r*   Úunconsumed_tailr,   s    r   r2   z GzipDecompressor.unconsumed_tail^   s   € ð ×!Ñ!×1Ñ1Ð1r   c                 ó6   — | j                   j                  «       S )zÉReturn any remaining buffered data not yet returned by decompress.

        Also checks for errors such as truncated input.
        No other methods may be called on this object after `flush`.
        )r*   Úflushr,   s    r   r4   zGzipDecompressor.flushc   s   € ð ×!Ñ!×'Ñ'Ó)Ð)r   ©r   N)r   )r    r!   r"   r#   r-   ÚbytesÚintr0   Úpropertyr2   r4   r   r   r   r&   r&   D   sR   „ ñóEñ@ ð @°3ð @¸uó @ð ð2 ò 2ó ð2ð*�uô *r   r&   r   r   c                 ó  — | j                  d«      dk(  rt        | «      S | j                  d«      }t        dj                  |dd «      |d   g¬«      }	 t	        ||d   «      S # t
        $ r t        d|d   z  «      ‚w xY w)a  Imports an object by name.

    ``import_object('x')`` is equivalent to ``import x``.
    ``import_object('x.y.z')`` is equivalent to ``from x.y import z``.

    >>> import tornado.escape
    >>> import_object('tornado.escape') is tornado.escape
    True
    >>> import_object('tornado.escape.utf8') is tornado.escape.utf8
    True
    >>> import_object('tornado') is tornado
    True
    >>> import_object('tornado.missing_module')
    Traceback (most recent call last):
        ...
    ImportError: No module named missing_module
    ú.r   Néÿÿÿÿ)ÚfromlistzNo module named %s)ÚcountÚ
__import__ÚsplitÚjoinÚgetattrr   ÚImportError)r   ÚpartsÚobjs      r   Úimport_objectrE   l   s‡   € ð$ ‡z�z�#ƒ˜!ÒÜ˜$ÓÐà�J‰J�s‹O€EÜ
�S—X‘X˜e C R˜jÓ)°U¸2±Y°KÔ
@€Cð<Ü�s˜E "™IÓ&Ð&øÜò <ÜÐ.°°r±Ñ:Ó;Ð;ð<ús   ÁA$ Á$A?ÚcodeÚglobÚlocc                 ó\   — t        | t        «      rt        | ddd¬«      } t        | ||«       y )Nz<string>ÚexecT)Údont_inherit)Ú
isinstancer$   ÚcompilerJ   )rF   rG   rH   s      r   Úexec_inrN   ‰   s,   € ô �$œÔô �t˜Z¨¸dÔCˆÜˆˆt�SÕr   Úexc_infor   c                 ó`   — 	 | d   �| d   j                  | d   «      ‚t        d«      ‚# d} w xY w)Né   é   z'raise_exc_info called with no exception)NNN)Úwith_tracebackÚ	TypeError)rO   s    r   Úraise_exc_inforU   “   s?   € ð&Ø�A‰;Ð"Ø˜1‘+×,Ñ,¨X°a©[Ó9Ð9äÐEÓFÐFøð &‰ús   ‚') ©-Úec                 ój   — t        | d«      r| j                  S | j                  r| j                  d   S y)aL  Provides the errno from an Exception object.

    There are cases that the errno attribute was not set so we pull
    the errno out of the args but if someone instantiates an Exception
    without any args you will get a tuple error. So this function
    abstracts all that behavior to give you a safe way to get the
    errno.
    Úerrnor   N)ÚhasattrrX   Úargs)rV   s    r   Úerrno_from_exceptionr[   ¡   s/   € ô ˆq�'ÔØ�w‰wˆØ	
�ŠØ�v‰v�a‰yÐàr   Ú>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789Úmatchc                 ó`   — | j                  d«      }|d   t        v rt        d|d   z  «      ‚|S )NrQ   r   zcannot unescape '\\%s')ÚgroupÚ	_alphanumÚ
ValueError)r]   r_   s     r   Ú_re_unescape_replacementrb   ¶   s5   € Ø�K‰K˜‹N€EØˆQ�x”9ÑÜÐ3°e¸A±hÑ>Ó?Ð?Ø€Lr   z\\(.)Úsc                 ó6   — t         j                  t        | «      S )z÷Unescape a string escaped by `re.escape`.

    May raise ``ValueError`` for regular expressions which could not
    have been produced by `re.escape` (for example, strings containing
    ``\d`` cannot be unescaped).

    .. versionadded:: 4.4
    )Ú_re_unescape_patternÚsubrb   )rc   s    r   Úre_unescaperg   À   s   € ô  ×#Ñ#Ô$<¸aÓ@Ð@r   c                   ó¦   ‡ — e Zd ZdZdZdZdededefˆ fd„Zed„ «       Z	ed„ «       Z
dd	„ZeZ	 ed
„ «       Zed„ «       Zed„ «       Zed„ «       Zˆ xZS )ÚConfigurablea*  Base class for configurable interfaces.

    A configurable interface is an (abstract) class whose constructor
    acts as a factory function for one of its implementation subclasses.
    The implementation subclass as well as optional keyword arguments to
    its initializer can be set globally at runtime with `configure`.

    By using the constructor as the factory method, the interface
    looks like a normal class, `isinstance` works as usual, etc.  This
    pattern is most useful when the choice of implementation is likely
    to be a global decision (e.g. when `~select.epoll` is available,
    always use it instead of `~select.select`), or when a
    previously-monolithic class has been split into specialized
    subclasses.

    Configurable subclasses must define the class methods
    `configurable_base` and `configurable_default`, and use the instance
    method `initialize` instead of ``__init__``.

    .. versionchanged:: 5.0

       It is now possible for configuration to be specified at
       multiple levels of a class hierarchy.

    NrZ   Úkwargsr   c                 ó@  •— | j                  «       }i }| |u r8| j                  «       }|j                  r|j                  |j                  «       n| }|j                  |«       |j                  «       |ur ||i |¤ŽS t        ‰| �  |«      } |j                  |i |¤Ž |S r   )Úconfigurable_baseÚconfigured_classÚ_Configurable__impl_kwargsÚupdateÚsuperÚ__new__Ú
initialize)ÚclsrZ   rj   ÚbaseÚinit_kwargsÚimplÚinstanceÚ	__class__s          €r   rq   zConfigurable.__new__ò   s¦   ø€ Ø×$Ñ$Ó&ˆØˆØ�$‰;Ø×'Ñ'Ó)ˆDØ×!Ò!Ø×"Ñ" 4×#5Ñ#5Õ6àˆDØ×Ñ˜6Ô"Ø×!Ñ!Ó#¨4Ñ/á˜Ð- Ñ-Ð-Ü‘7‘? 4Ó(ˆð 	ˆ×Ñ˜TÐ1 [Ò1Øˆr   c                 ó   — t        «       ‚)zÞReturns the base class of a configurable hierarchy.

        This will normally return the class in which it is defined.
        (which is *not* necessarily the same as the ``cls`` classmethod
        parameter).

        ©ÚNotImplementedError©rs   s    r   rl   zConfigurable.configurable_base  s   € ô "Ó#Ð#r   c                 ó   — t        «       ‚)zBReturns the implementation class to be used if none is configured.rz   r|   s    r   Úconfigurable_defaultz!Configurable.configurable_default  s   € ô "Ó#Ð#r   c                  ó   — y r   r   r,   s    r   Ú_initializezConfigurable._initialize  s   € Ør   c                 óì   — | j                  «       }t        |t        «      r*t        j                  t
        t           t        |«      «      }|�t        || «      st        d| z  «      ‚||_
        ||_        y)zðSets the class to use when the base class is instantiated.

        Keyword arguments will be saved and added to the arguments passed
        to the constructor.  This can be used to set global defaults for
        some parameters.
        NzInvalid subclass of %s)rl   rL   r$   ÚtypingÚcastr   ri   rE   Ú
issubclassra   Ú_Configurable__impl_classrn   )rs   rv   rj   rt   s       r   Ú	configurezConfigurable.configure$  sf   € ð ×$Ñ$Ó&ˆÜ�dœCÔ Ü—;‘;œt¤LÑ1´=ÀÓ3FÓGˆDØÐ¤J¨t°SÔ$9ÜÐ5¸Ñ;Ó<Ð<Ø ˆÔØ#ˆÕr   c                 óÈ   — | j                  «       }|j                  j                  d«      €| j                  «       |_        |j                  �|j                  S t        d«      ‚)z'Returns the currently configured class.r…   zconfigured class not found)rl   Ú__dict__Úgetr~   r…   ra   ©rs   rt   s     r   rm   zConfigurable.configured_class5  sa   € ð ×$Ñ$Ó&ˆð �=‰=×ÑÐ8Ó9ÐAØ #× 8Ñ 8Ó :ˆDÔØ×ÑÐ(Ø×$Ñ$Ð$ô Ð9Ó:Ð:r   c                 óR   — | j                  «       }|j                  |j                  fS r   ©rl   r…   rn   rŠ   s     r   Ú_save_configurationz Configurable._save_configurationE  s)   € ð ×$Ñ$Ó&ˆØ×!Ñ! 4×#5Ñ#5Ð6Ð6r   c                 óL   — | j                  «       }|d   |_        |d   |_        y )Nr   rQ   rŒ   )rs   Úsavedrt   s      r   Ú_restore_configurationz#Configurable._restore_configurationK  s*   € ð ×$Ñ$Ó&ˆØ! !™HˆÔØ" 1™XˆÕr   r5   )r    r!   r"   r#   r…   rn   r   rq   Úclassmethodrl   r~   r€   rr   r†   rm   r�   r�   Ú__classcell__)rx   s   @r   ri   ri   Ì   s¸   ø„ ñðD €LØ€Mð˜Cð ¨3ð °3õ ð( ñ	$ó ð	$ð ñ$ó ð$ó
ð €Jðð ñ$ó ð$ð  ñ;ó ð;ð ñ7ó ð7ð
 ñ&ó ô&r   ri   c                   óª   — e Zd ZdZdededdfd„Zdedee   fd„Z	 dde	e
   d	eee
f   d
e
de
fd„Zde
de	e
   d	eee
f   dee
e	e
   eee
f   f   fd„Zy)ÚArgReplacerz×Replaces one value in an ``args, kwargs`` pair.

    Inspects the function signature to find an argument by name
    whether it is passed by position or keyword.  For use in decorators
    and similar wrappers.
    Úfuncr   r   Nc                 óŠ   — || _         	 | j                  |«      j                  |«      | _        y # t        $ r
 d | _        Y y w xY wr   )r   Ú_getargnamesÚindexÚarg_posra   )r   r•   r   s      r   r-   zArgReplacer.__init__[  sA   € ØˆŒ	ð	 Ø×,Ñ,¨TÓ2×8Ñ8¸Ó>ˆD�LøÜò 	 àˆDŽLð	 ús   ‰%/ ¯AÁAc                 ó°   — 	 t        |«      j                  S # t        $ r5 t        |d«      r'|j                  }|j
                  d |j                   cY S ‚ w xY w)NÚ	func_code)r   rZ   rT   rY   r›   Úco_varnamesÚco_argcount)r   r•   rF   s      r   r—   zArgReplacer._getargnamesc  sY   € ð	Ü! $Ó'×,Ñ,Ð,øÜò 
	Ü�t˜[Ô)ð —~‘~�Ø×'Ñ'Ð(:¨$×*:Ñ*:Ð;Ò;Øð
	ús   ‚ —:AÁArZ   rj   Údefaultc                 ó    — | j                   �'t        |«      | j                   kD  r|| j                      S |j                  | j                  |«      S )z‡Returns the old value of the named argument without replacing it.

        Returns ``default`` if the argument is not present.
        )r™   Úlenr‰   r   )r   rZ   rj   rž   s       r   Úget_old_valuezArgReplacer.get_old_valuer  sA   € ð �<‰<Ð#¬¨D«	°D·L±LÒ(@Ø˜Ÿ™Ñ%Ð%à—:‘:˜dŸi™i¨Ó1Ð1r   Ú	new_valuec                 óü   — | j                   �Bt        |«      | j                   kD  r*|| j                      }t        |«      }||| j                   <   n*|j                  | j                  «      }||| j                  <   |||fS )a”  Replace the named argument in ``args, kwargs`` with ``new_value``.

        Returns ``(old_value, args, kwargs)``.  The returned ``args`` and
        ``kwargs`` objects may not be the same as the input objects, or
        the input objects may be mutated.

        If the named argument was not found, ``new_value`` will be added
        to ``kwargs`` and None will be returned as ``old_value``.
        )r™   r    Úlistr‰   r   )r   r¢   rZ   rj   Ú	old_values        r   ÚreplacezArgReplacer.replace~  sq   € ð �<‰<Ð#¬¨D«	°D·L±LÒ(@à˜TŸ\™\Ñ*ˆIÜ˜“:ˆDØ!*ˆD�—‘Òð Ÿ
™
 4§9¡9Ó-ˆIØ )ˆF�4—9‘9ÑØ˜$ Ð&Ð&r   r   )r    r!   r"   r#   r   r$   r-   r   r—   r   r   r   r¡   r	   r¦   r   r   r   r”   r”   S  s¹   „ ñð ˜Xð  ¨Sð  °Tó  ð ð ¨d°3©ió ð  KOñ
2Ø˜S‘Mð
2Ø+/°°S°©>ð
2ØDGð
2à	ó
2ð'Øð'Ø$,¨S¡Mð'Ø;?ÀÀSÀ¹>ð'à	ˆs�H˜S‘M 4¨¨S¨¡>Ð1Ñ	2ô'r   r”   c                 ó"   — | j                  «       S )z@Equivalent to ``td.total_seconds()`` (introduced in Python 2.7).)Útotal_seconds)Útds    r   Útimedelta_to_secondsrª   –  s   € ð ×ÑÓÐr   ÚmaskÚdatac                 óÎ   — t        j                   d| «      }t        j                   d|«      }t        t        |«      «      D ]  }||   ||dz     z  ||<   Œ |j                  «       S )aQ  Websocket masking function.

    `mask` is a `bytes` object of length 4; `data` is a `bytes` object of any length.
    Returns a `bytes` object of the same length as `data` with the mask applied
    as specified in section 5.3 of RFC 6455.

    This pure-python implementation may be replaced by an optimized version when available.
    ÚBé   )ÚarrayÚranger    Útobytes)r«   r¬   Úmask_arrÚunmasked_arrÚis        r   Ú_websocket_mask_pythonr¶   œ  se   € ô �{‰{˜3 Ó%€HÜ—;‘;˜s DÓ)€LÜ”3�t“9Óò <ˆØ& q™/¨H°Q¸±U©OÑ;ˆ�QŠð<à×ÑÓ!Ð!r   ÚTORNADO_NO_EXTENSIONÚTORNADO_EXTENSIONÚ0)Úwebsocket_maskÚ1c                  ó*   — dd l } | j                  «       S )Nr   )ÚdoctestÚDocTestSuite)r½   s    r   Údoctestsr¿   ¹  s   € ãà×ÑÓ!Ð!r   r   );r#   r°   ÚasyncioÚinspectr   ÚosÚrer‚   r)   r   r   r   r   r   r	   r
   r   r   r   ÚTYPE_CHECKINGÚdatetimeÚtypesr   r   Úunittestr6   Ú
bytes_typer$   Úunicode_typeÚbasestring_typeÚTimeoutErrorr   r&   rE   rN   ÚtypeÚBaseExceptionÚNoReturnrU   r7   r[   Ú	frozensetr`   rb   rM   ÚDOTALLre   rg   ri   r”   rª   r¶   Úenvironr‰   Ú_websocket_maskÚtornado.speedupsrº   rB   r¿   r   r   r   ú<module>rÔ      s,  ðñ
ó Û Ý "Û 	Û 	Û Û ÷÷ ÷ ð 
×Òó Ý#ÝÛð
 €
Ø€Ø€ð
 ×#Ñ#€ô
��c˜3�h‘ô 
÷%*ñ %*ðP<˜ð < ó <ð< SWñØ
ðØ˜#˜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ó ð "�r—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   Å0E: Å:&F&Æ%F&