K i= RdZddlZddlZddlmZddlZddlZddlZddlZddlm Z m Z m Z m Z m Z mZmZmZmZmZej&rddlZddlmZddlmZddlZeZeZeZej<ZGdde ee fZGd d Z d ed e fd Z! d+de de ee fde e e ee fd dfdZ"dee e#e e$e dfd ejJfdZ&de$d e e'fdZ(e)dZ*deed efdZ+ejXdejZZ.ded efdZ/GddZ0Gdd Z1d!Z2d"ed#ed efd$Z3ejhjkd%sejhjkd&d'k(re3Z6d*Z:y dd(l7m8Z6d*Z:y#e9$r'ejhjkd&d)k(re3Z6Yd*Z:ywxYw),aMiscellaneous 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) AnyOptionalDictMappingListTupleMatchCallableTypeSequence) TracebackType)Unionc4eZdZdZdedefdZdededdfdZy) ObjectDictzFMakes a dictionary behave like an object, with attribute-style access.namereturnc> ||S#t$r t|wxYwN)KeyErrorAttributeError)selfrs R/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/tornado/util.py __getattr__zObjectDict.__getattr__:s+ ':  ' & & 'svalueNc|||<yr)rrrs r __setattr__zObjectDict.__setattr__@s T )__name__ __module__ __qualname____doc__strrrrrrrrr7s2P''' CDrrcPeZdZdZd dZd dededefdZedefdZ defd Z y) GzipDecompressorzStreaming gzip decompressor. The interface is like that of `zlib.decompressobj` (without some of the optional arguments, but it understands gzip headers and checksums. rNcZtjdtjz|_y)N)zlib decompressobj MAX_WBITSrs r__init__zGzipDecompressor.__init__Ks "//T^^0CDrr max_lengthc:|jj||S)aDecompress 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)rrr.s rr0zGzipDecompressor.decompressQs!!,,UJ??rc.|jjS)z(Returns the unconsumed portion left over)r*unconsumed_tailr,s rr2z GzipDecompressor.unconsumed_tail^s!!111rc6|jjS)zReturn 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 rr4zGzipDecompressor.flushcs !!''))rrN)r) r r!r"r#r-bytesintr0propertyr2r4rrrr&r&DsR E @ @3 @u @222*u*rr&rrc|jddk(r t|S|jd}tdj|dd|dg} t ||dS#t $rt d|dzwxYw)aImports 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 .rN)fromlistzNo module named %s)count __import__splitjoingetattrr ImportError)rpartsobjs r import_objectrEls$ zz#!$ JJsOE SXXeCRj)U2YK @C<sE"I&& <.r:;;execT) dont_inherit) isinstancer$compilerJ)rFrGrHs rexec_inrNs,$tZdCtSrexc_inforc` |d|dj|dtd#d}wxYw)Nz'raise_exc_info called with no exception)NNN)with_traceback TypeError)rOs rraise_exc_inforUs?& A; "1+,,Xa[9 9EF F&s')-ecjt|dr |jS|jr|jdSy)aLProvides 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. errnorN)hasattrrXargs)rVs rerrno_from_exceptionr[s/q'ww vvayr>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789matchc`|jd}|dtvrtd|dz|S)NrQrzcannot unescape '\\%s')group _alphanum ValueError)r]r_s r_re_unescape_replacementrbs5 KKNE Qx93eAh>?? Lrz\\(.)sc6tjt|S)zUnescape 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_patternsubrb)rcs r re_unescapergs # #$DL DL s%/AAc t|jS#t$r5t|dr'|j}|j d|j cYSwxYw)N func_code)rrZrTrYr co_varnames co_argcount)rrrFs rrzArgReplacer._getargnamescsY !$',, , t[)~~''(:$*:*:;;  s:AArZrjdefaultc|j't||jkDr||jS|j|j|S)zReturns the old value of the named argument without replacing it. Returns ``default`` if the argument is not present. )rlenrr)rrZrjrs r get_old_valuezArgReplacer.get_old_valuersA << #D DLL(@ % %::dii1 1r new_valuec|jBt||jkDr*||j}t|}|||j<n*|j|j}|||j<|||fS)aReplace 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``. )rrlistrr)rrrZrj old_values rreplacezArgReplacer.replace~sq << #D DLL(@T\\*I:D!*D  499-I )F499 $&&rr)r r!r"r#r r$r-rrr rrrr rrrrrrSs X S T   d3i  KO 2SM 2+/S> 2DG 2  2''$,SM';?S>' sHSM4S>1 2'rrc"|jS)z@Equivalent to ``td.total_seconds()`` (introduced in Python 2.7).) total_seconds)tds rtimedelta_to_secondsrs    rmaskdatactjd|}tjd|}tt|D]}||||dzz ||<|jS)aQWebsocket 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)arrayrangertobytes)rrmask_arr unmasked_arris r_websocket_mask_pythonrse{{3%H;;sD)L 3t9 <&q/HQUO; Q<    !!rTORNADO_NO_EXTENSIONTORNADO_EXTENSION0)websocket_mask1c*ddl}|jS)Nr)doctest DocTestSuite)rs rdoctestsrs    !!rr);r#rasyncioinspectrosrerr)rrrrrr r r r r TYPE_CHECKINGdatetimetypesrrunittestr6 bytes_typer$ unicode_typebasestring_type TimeoutErrorrr&rErNtype BaseExceptionNoReturnrUr7r[ frozensetr`rbrMDOTALLrergrirrrenvironr_websocket_masktornado.speedupsrrBrrrrrs,  "     #    ##  c3h %*%*P<<<<SW #s(^*28GCH>()RZZ^^>- .# 5 0" 1s0E::&F&%F&