U `;*@sddlmZzddlmZmZWn$ek rDddlmZmZYnXzddlmZWn"ek rxGdddZYnXddlm Z ddl m Z dd l m Z dd lmZmZd d gZeZGd d d eZGdd d eZdS))absolute_import)MappingMutableMapping)RLockc@seZdZddZddZdS)rcCsdSNselfrrE/opt/alt/python38/lib/python3.8/site-packages/urllib3/_collections.py __enter__ szRLock.__enter__cCsdSrr)r exc_type exc_value tracebackrrr __exit__szRLock.__exit__N)__name__ __module__ __qualname__r rrrrr r sr) OrderedDict) InvalidHeader)six)iterkeys itervaluesRecentlyUsedContainerHTTPHeaderDictc@sVeZdZdZeZdddZddZdd Zd d Z d d Z ddZ ddZ ddZ dS)ra 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 NcCs"||_||_||_t|_dSr)_maxsize dispose_func ContainerCls _containerrlock)r maxsizerrrr __init__/s zRecentlyUsedContainer.__init__c Cs8|j(|j|}||j|<|W5QRSQRXdSr)r rpop)r keyitemrrr __getitem__6s  z!RecentlyUsedContainer.__getitem__c Cslt}|j@|j|t}||j|<t|j|jkrF|jjdd\}}W5QRX|jrh|tk rh||dS)NF)last)_Nullr rgetlenrpopitemr)r r$valueZ evicted_value_keyrrr __setitem__=s z!RecentlyUsedContainer.__setitem__c Cs2|j|j|}W5QRX|jr.||dSr)r rr#r)r r$r,rrr __delitem__Lsz!RecentlyUsedContainer.__delitem__c Cs(|jt|jW5QRSQRXdSr)r r*rrrrr __len__SszRecentlyUsedContainer.__len__cCs tddS)Nz7Iteration over this class is unlikely to be threadsafe.)NotImplementedErrorrrrr __iter__WszRecentlyUsedContainer.__iter__c CsH|jtt|j}|jW5QRX|jrD|D]}||q4dSr)r listrrclearr)r valuesr,rrr r4\s zRecentlyUsedContainer.clearc Cs,|jtt|jW5QRSQRXdSr)r r3rrrrrr keysfszRecentlyUsedContainer.keys)rN)rrr__doc__rrr"r&r.r/r0r2r4r6rrrr rs   cseZdZdZd-fdd ZddZddZd d Zd d Zd dZ ddZ e j r\e jZe jZeZddZddZefddZddZddZddZefddZeZeZeZeZdd Zd!d"Zd#d$Zd%d&Z d'd(Z!d)d*Z"e#d+d,Z$Z%S).rap :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' Nc sPtt|t|_|dk r>t|tr4||n |||rL||dSr)superrr"rr isinstance _copy_fromextend)r headerskwargs __class__rr r"s   zHTTPHeaderDict.__init__cCs ||g|j|<|j|Srrlowerr r$valrrr r.szHTTPHeaderDict.__setitem__cCs |j|}d|ddS)N, rrrAjoinrBrrr r&szHTTPHeaderDict.__getitem__cCs|j|=dSrr@r r$rrr r/szHTTPHeaderDict.__delitem__cCs||jkSr)rArrGrrr __contains__szHTTPHeaderDict.__contains__cCs^t|tst|dsdSt|t|s2t||}tdd|Dtdd|DkS)Nr6Fcss|]\}}||fVqdSr)rA).0kvrrr sz(HTTPHeaderDict.__eq__..)r9rhasattrtypedict itermergedr otherrrr __eq__s zHTTPHeaderDict.__eq__cCs || Sr)rSrQrrr __ne__szHTTPHeaderDict.__ne__cCs t|jSr)r*rrrrr r0szHTTPHeaderDict.__len__ccs|jD]}|dVq dS)Nr)rr5)r valsrrr r2szHTTPHeaderDict.__iter__cCs@z ||}Wn$tk r0||jkr(|YSX||=|SdS)zD.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised. N)KeyError_HTTPHeaderDict__marker)r r$defaultr,rrr r#s   zHTTPHeaderDict.popcCs$z ||=Wntk rYnXdSr)rVrGrrr discards zHTTPHeaderDict.discardcCs4|}||g}|j||}||k r0||dS)zAdds a (name, value) pair, doesn't overwrite the value if it already exists. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz' N)rAr setdefaultappend)r r$rCZ key_lowerZnew_valsrUrrr adds zHTTPHeaderDict.addcOst|dkrtdt|t|dkr2|dnd}t|tr`|D]\}}|||qHnjt|tr|D]}||||qnnDt|dr| D]}||||qn|D]\}}|||q| D]\}}|||qdS)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__ rz9extend() takes at most 1 positional arguments ({0} given)rrr6N) r* TypeErrorformatr9r iteritemsr\rrMr6items)r argsr=rRr$rCr,rrr r;s(      zHTTPHeaderDict.extendcCsNz|j|}Wn*tk r<||jkr4gYS|YSX|ddSdS)zmReturns a list of all the values for the named field. Returns an empty list if the key doesn't exist.rN)rrArVrW)r r$rXrUrrr getlists  zHTTPHeaderDict.getlistcCsdt|jt|fS)Nz%s(%s))rNrrOrPrrrr __repr__szHTTPHeaderDict.__repr__cCs>|D]4}||}t|tr$t|}|g||j|<qdSr)rbr9r3rrA)r rRr$rCrrr r:s   zHTTPHeaderDict._copy_fromcCst|}|||Sr)rNr:)r clonerrr copy"s  zHTTPHeaderDict.copyccs<|D]2}|j|}|ddD]}|d|fVq"qdS)z8Iterate over all header lines, including duplicate ones.rNrr@)r r$rUrCrrr r_'szHTTPHeaderDict.iteritemsccs8|D].}|j|}|dd|ddfVqdS)z:Iterate over all headers, merging duplicate ones together.rrDrNrErBrrr rP.szHTTPHeaderDict.itermergedcCs t|Sr)r3r_rrrr r`4szHTTPHeaderDict.itemscCsd}g}|jD]h}||rT|s.td|n&|d\}}||d|f|d<q|dd\}}|||fq||S)z4Read headers from a Python 2 httplib message object.)  z/Header continuation with no previous header: %srf:r)r< startswithrstripsplitr[)clsmessageZobs_fold_continued_leadersr<liner$r,rrr from_httplib7s   zHTTPHeaderDict.from_httplib)N)&rrrr7r"r.r&r/rHrSrTrPY2rrrobjectrWr0r2r#rYr\r;rbZ getheadersZgetallmatchingheadersZigetget_allrcr:rer_rPr` classmethodrp __classcell__rrr>r rks>!    N) __future__rcollections.abcrr ImportError collections threadingrr exceptionsrpackagesrZ packages.sixrr__all__rrr(rrrrrr s    L