iD2ddlmZddlZddlmZddlmZmZddlm Z ej rddlm Z ddl m Z Gdd e Zd d gZejd Zejd ZejdZejd ejeefejeeefd fZGddeZddZGdd ejeefejeefZGddeeeefZ Gdd ejeefZ!dS)) annotationsN) OrderedDict)Enumauto)RLock)Protocol)SelfceZdZddZd dZdS) HasGettableStringKeysreturntyping.Iterator[str]cdSNselfs BC:\PYTHON\_runtimes\venv\Lib\site-packages\urllib3/_collections.pykeyszHasGettableStringKeys.keyskeystrcdSrrrrs r __getitem__z!HasGettableStringKeys.__getitem__rrNr r rrr r)__name__ __module__ __qualname__rrrrrr r s(3333333333rr RecentlyUsedContainerHTTPHeaderDict_KT_VT_DTc"eZdZeZdS) _SentinelN)rrr r not_passedrrrr'r''sJJJrr' potentialobjectr ValidHTTPHeaderSource | Nonect|tr|St|tjr1tjtjt t f|St|tjr#s(3Y??? Iv / /{6?5c?;YGGG F # # =(I(I{2I>>>trceZdZUdZded<ded<ded<ded < ddfd ZddZd dZd!dZd"dZ d#dZ d$dZ d%dZ xZ S)&r!a Provides a thread-safe dict-like container which maintains up to ``maxsize`` keys while throwing away the least-recently-used keys beyond ``maxsize``. :param maxsize: Maximum number of recent elements to retain. :param dispose_func: Every time an item is evicted from the container, ``dispose_func(value)`` is called. Callback which will get called ztyping.OrderedDict[_KT, _VT] _containerint_maxsize#typing.Callable[[_VT], None] | None dispose_funcrlock Nmaxsizer Nonect||_||_t |_t |_dSr)super__init__r8r:rr6rr;)rr=r: __class__s rrAzRecentlyUsedContainer.__init__RsD  (%--GG rrr#r$c|j5|j|}||j|<|cdddS#1swxYwYdSr)r;r6pop)rritems rrz!RecentlyUsedContainer.__getitem__]s Y  ?&&s++D#'DOC                    &;??valuecd}|j5 ||j|f}||j|<nR#t$rE||j|<t |j|jkr|jd}YnwxYwdddn #1swxYwY|#|jr|\}}||dSdSdS)NF)last)r;r6rDKeyErrorlenr8popitemr:)rrrG evicted_item_ evicted_values r __setitem__z!RecentlyUsedContainer.__setitem__dsH Y G G G #DO$7$7$<$<< ',$$ G G G(-$t''$-77$(?#:#:#:#F#FL G G G G G G G G G G G G G G G G&  #(9 #+ A}   m , , , , , $ # # #s2B&3BA B?BBBBBc|j5|j|}dddn #1swxYwY|jr||dSdSr)r;r6rDr:)rrrGs r __delitem__z!RecentlyUsedContainer.__delitem__}s Y - -O'',,E - - - - - - - - - - - - - - -   %   e $ $ $ $ $ % %s /33cl|j5t|jcdddS#1swxYwYdSr)r;rKr6rs r__len__zRecentlyUsedContainer.__len__s{ Y ( (t'' ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (s )--typing.NoReturnc td)Nz7Iteration over this class is unlikely to be threadsafe.)NotImplementedErrorrs r__iter__zRecentlyUsedContainer.__iter__s! E   rc|j5t|j}|jdddn #1swxYwY|jr|D]}||dSdSr)r;listr6valuesclearr:)rr[rGs rr\zRecentlyUsedContainer.clears Y $ $$/002233F O ! ! # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $   ) ) )!!%(((( ) ) ) )sAAAAset[_KT]c|j5t|jcdddS#1swxYwYdSr)r;setr6rrs rrzRecentlyUsedContainer.keyss Y / /t++--.. / / / / / / / / / / / / / / / / / /rF)r<N)r=r7r:r9r r>)rr#r r$)rr#rGr$r r>)rr#r r>r r7)r rU)r r>)r r])rrr __doc____annotations__rArrPrRrTrXr\r __classcell__rBs@rr!r!?s  -,,,MMM5555KKK<@       ----2%%%%((((    ))))////////rc>eZdZUdZded<ddZdd Zdd ZddZdS)HTTPHeaderDictItemViewa HTTPHeaderDict is unusual for a Mapping[str, str] in that it has two modes of address. If we directly try to get an item with a particular name, we will get a string back that is the concatenated version of all the values: >>> d['X-Header-Name'] 'Value1, Value2, Value3' However, if we iterate over an HTTPHeaderDict's items, we will optionally combine these values based on whether combine=True was called when building up the dictionary >>> d = HTTPHeaderDict({"A": "1", "B": "foo"}) >>> d.add("A", "2", combine=True) >>> d.add("B", "bar") >>> list(d.items()) [ ('A', '1, 2'), ('B', 'foo'), ('B', 'bar'), ] This class conforms to the interface required by the MutableMapping ABC while also giving us the nonstandard iteration behavior we want; items with duplicate keys, ordered by time of first insertion. r"_headersheadersr r>c||_dSr)rg)rrhs rrAzHTTPHeaderDictItemView.__init__s  rr7chtt|jSr)rKrZrg iteritemsrs rrTzHTTPHeaderDictItemView.__len__s&4 //1122333r typing.Iterator[tuple[str, str]]c4|jSr)rgrkrs rrXzHTTPHeaderDictItemView.__iter__s}&&(((rrEr*boolct|tr]t|dkrJ|\}}t|tr0t|tr|j||SdS)NF)r-r2rKrrg_has_value_for_header)rrE passed_key passed_vals r __contains__z#HTTPHeaderDictItemView.__contains__so dE " " Ss4yyA~~%) "J *c** Sz*c/J/J S}:::zRRRurN)rhr"r r>r`r rl)rEr*r rn) rrr rarbrArTrXrtrrrrfrfs~8    4444))))rrfc`eZdZUdZded<d=d>fd Zd?dZd@dZdAdZdBdZ dCdDfd Z dEdZ dEdZ dFdZ dGdZdAdZdd dHd"ZdId%ZejdJd'ZejdKd*ZejfdLd,ZdMd.ZeZeZeZeZdNd/ZdOd0ZdMd1ZdPd3ZdPd4Z dQd6Z!dRd9Z"dSd:Z#dTd;Z$dTd<Z%xZ&S)Ur"ap :param headers: An iterable of field-value pairs. Must not contain multiple field names when compared case-insensitively. :param kwargs: Additional field-value pairs to pass in to ``dict.update``. A ``dict`` like container for storing HTTP Headers. Field names are stored and compared case-insensitively in compliance with RFC 7230. Iteration provides the first case-sensitive key seen for each case-insensitive pair. Using ``__setitem__`` syntax overwrites fields that compare equal case-insensitively in order to maintain ``dict``'s api. For fields that compare equal, instead create a new ``HTTPHeaderDict`` and use ``.add`` in a loop. If multiple fields that are equal case-insensitively are passed to the constructor or ``.update``, the behavior is undefined and some will be lost. >>> headers = HTTPHeaderDict() >>> headers.add('Set-Cookie', 'foo=bar') >>> headers.add('set-cookie', 'baz=quxx') >>> headers['content-length'] = '7' >>> headers['SET-cookie'] 'foo=bar, baz=quxx' >>> headers['Content-Length'] '7' z%typing.MutableMapping[str, list[str]]r6Nrhr+kwargsrc  ti|_|@t|tr||n|||r||dSdSr)r@rAr6r-r" _copy_fromextend)rrhrwrBs rrAzHTTPHeaderDict.__init__s   '>22 %(((( G$$$  KK       rrvalr r>ct|tr|d}||g|j|<dSNlatin-1r-bytesdecoder6lowerrrr{s rrPzHTTPHeaderDict.__setitem__sC c5 ! ! (**Y''C(+Sz $$$rct|tr|d}|j|}d|ddS)Nr~, )r-rrr6rjoinrs rrzHTTPHeaderDict.__getitem__sS c5 ! ! (**Y''Cociikk*yyQRR!!!rct|tr|d}|j|=dSr}rrs rrRzHTTPHeaderDict.__delitem__s= c5 ! ! (**Y''C OCIIKK ( ( (rr*rnct|tr|d}t|tr||jvSdS)Nr~F)r-rrrrr6rs rrtzHTTPHeaderDict.__contains__ sQ c5 ! ! (**Y''C c3   299;;$/1 1urdefaultcHt||Sr)r@ setdefault)rrrrBs rrzHTTPHeaderDict.setdefaultsww!!#w///rotherct|}|dSt||}d|Dd|DkS)NFc>i|]\}}||Srr.0kvs r z)HTTPHeaderDict.__eq__..s&;;;A 1;;;rc>i|]\}}||Srrrs rrz)HTTPHeaderDict.__eq__..s9@ @ @ !QAGGIIq@ @ @ r)r4type itermerged)rrmaybe_constructableother_as_http_header_dicts r__eq__zHTTPHeaderDict.__eq__sCEJJ  &5(2T 3F(G(G %;;):):;;;@ @ %>%I%I%K%K@ @ @   rc.|| Sr)r)rrs r__ne__zHTTPHeaderDict.__ne__!s;;u%%%%rr7c*t|jSr)rKr6rs rrTzHTTPHeaderDict.__len__$s4?###rr c#VK|jD] }|dV dS)Nr)r6r[)rvalss rrXzHTTPHeaderDict.__iter__'s<O**,,  Dq'MMMM  rc0 ||=dS#t$rYdSwxYwr)rJrs rdiscardzHTTPHeaderDict.discard,s4 S     DD s  F)combinercJt|tr|d}|}||g}|j||}||urAt |dksJ|r|ddz|z|d<dS||dSdS)aAdds a (name, value) pair, doesn't overwrite the value if it already exists. If this is called with combine=True, instead of adding a new header value as a distinct item during iteration, this will instead append the value to any existing header value with a comma. If no existing header value exists for the key, then the value will simply be added, ignoring the combine parameter. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz' >>> list(headers.items()) [('foo', 'bar'), ('foo', 'baz')] >>> headers.add('foo', 'quz', combine=True) >>> list(headers.items()) [('foo', 'bar, baz, quz')] r~rprN)r-rrrr6rrKappend)rrr{r key_lowernew_valsrs raddzHTTPHeaderDict.add2s( c5 ! ! (**Y''CIIKK :)))X>> 4  t99>>>> !8d?S0R C      rargsValidHTTPHeaderSourcect|dkr tdt|dt|dkr|dnd}t|tr2|D]\}}|||nt|t jr1|D]\}}|||nt|t j r[t j t j tttf|}|D]\}}|||nSt|drCt|dr3|D]}|||||D]\}}|||dS) zGeneric import function for any type of header-like object. Adapted version of MutableMapping.update in order to insert items with self.add instead of self.__setitem__ rz/extend() takes at most 1 positional arguments (z given)rrrrN)rK TypeErrorr-r"rkrr.r/itemsr1r0r2rr3r)rrrwrrr{rGs rrzzHTTPHeaderDict.extendUs t99q==T#d))TTT t99>>Qr e^ , , *!OO-- # #Sc"""" # v~ . . *!KKMM # #Sc"""" # v / / *Kc3h @%HHE# % % Ue$$$$ % UF # # *}(E(E * zz|| * *eCj)))) ,,.. ! !JC HHS%  ! !r list[str]cdSrrrs rgetlistzHTTPHeaderDict.getlistvs.1crr%list[str] | _DTcdSrr)rrrs rrzHTTPHeaderDict.getlistysBE#r_Sentinel | _DTct|tr|d} |j|}|ddS#t $r|t jurgcYS|cYSwxYw)zmReturns a list of all the values for the named field. Returns an empty list if the key doesn't exist.r~rN)r-rrr6rrJr'r()rrrrs rrzHTTPHeaderDict.getlist|s c5 ! ! (**Y''C ?399;;/D8O   )... NNN  sAA61A65A6r cBgd}|D]}|||S)z Remove content-specific header fields before changing the request method to GET or HEAD according to RFC 9110, Section 15.4. )zContent-EncodingzContent-LanguagezContent-Locationz Content-TypezContent-LengthDigestz Last-Modified)r)rcontent_specific_headersheaders r_prepare_for_method_changez)HTTPHeaderDict._prepare_for_method_changes? $ $ $  / ! !F LL  rctt|jdt|dS)N())rrdictrrs r__repr__zHTTPHeaderDict.__repr__s4t**%BBT__->->(?(?BBBBrcx|D]6}||}|g||j|<7dSr)rr6r)rrrr{s rryzHTTPHeaderDict._copy_fromsI 7 7C--$$C,/;#;DOCIIKK ( ( 7 7rc^t|}|||Sr)rry)rclones rcopyzHTTPHeaderDict.copys,T   rrlc#K|D]:}|j|}|ddD]}|d|fV;dS)z8Iterate over all header lines, including duplicate ones.rNrr6r)rrrr{s rrkzHTTPHeaderDict.iteritemssf # #C?399;;/DABBx # #1gsl"""" # # #rc#K|D]H}|j|}|dd|ddfVIdS)z:Iterate over all headers, merging duplicate ones together.rrrN)r6rrrs rrzHTTPHeaderDict.itermergeds_ - -C/#))++.Ca&$))CG,,, , , , , - -rrfc t|Sr)rfrs rrzHTTPHeaderDict.itemss%d+++r header_namepotential_valuec`||vr)||j|ddvSdS)NrFr)rrrs rrqz$HTTPHeaderDict._has_value_for_headers9 $  "dok6G6G6I6I&J122&NN Nurc`t|}|tS|||Sr)r4NotImplementedrz)rrrs r__ior__zHTTPHeaderDict.__ior__s7DEJJ  &! ! '((( rct|}|tS|}|||Sr)r4rrrzrrrresults r__or__zHTTPHeaderDict.__or__sDDEJJ  &! ! )*** rct|}|tSt||}|||Sr)r4rrrzrs r__ror__zHTTPHeaderDict.__ror__sLDEJJ  &! !d/00 d rr)rhr+rwr)rrr{rr r>r)rrr r>)rr*r rn)r)rrrrr r)rr*r rnr`r)rrr{rrrnr r>)rrrwrr r>)rrr r)rrrr%r r)rrrrr r)r r )r r)rr"r r>ru)r rf)rrrrr rn)rr*r r")rr*r r )'rrr rarbrArPrrRrtrrrrTrXrrrzr.overloadrr'r(r getheadersgetallmatchingheadersigetget_allrryrrkrrrqrrrrcrds@rr"r"sB6555        2222 """" )))) 0000000     &&&&$$$$  :?!!!!!!!!!!!!F!!!!B _111_1 _EEE_E4=3G(&J# DGCCCC7777  ####---- ,,,, r)r)r*r r+)" __future__rr. collectionsrenumrr threadingr TYPE_CHECKINGrtyping_extensionsr r __all__TypeVarr#r$r%Unionr/rr1r2rr'r4GenericMutableMappingr!r_rfr"rrrrs>"""""" ######  4 &&&&&&44444444 #$4 5fnUfnUfnU  N38 OE#s(O$(Z/Z/Z/Z/Z/FN384f6KCQTH6UZ/Z/Z/z-----SsCx1---`[[[[[V*384[[[[[r