abc@@sddlmZddlmZmZyddlmZWn$ek r`dddYZnXyddlmZWn!ek rddl mZnXddl m Z m Z m Z d d gZeZd efd YZd efd YZd S(i(tabsolute_import(tMappingtMutableMapping(tRLockRcB@seZdZdZRS(cC@sdS(N((tself((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pyt __enter__scC@sdS(N((Rtexc_typet exc_valuet traceback((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pyt__exit__ s(t__name__t __module__RR (((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pyRs (t OrderedDicti(titerkeyst itervaluestPY3tRecentlyUsedContainertHTTPHeaderDictcB@sbeZdZeZdd dZdZdZdZ dZ dZ dZ d Z RS( s 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 i cC@s1||_||_|j|_t|_dS(N(t_maxsizet dispose_funct ContainerClst _containerRtlock(RtmaxsizeR((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pyt__init__+s  cC@s7|j(|jj|}||j|<|SWdQXdS(N(RRtpop(Rtkeytitem((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pyt __getitem__2s  cC@st}|j]|jj|t}||j|>> 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' cK@sttt|jt|_|dk rZt|trJ|j|qZ|j|n|rp|j|ndS(N( tsuperRRR RR0t isinstancet _copy_fromtextend(Rtheaderstkwargs((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pyRs  cC@s*||g|j|j<|j|jS(N(Rtlower(RRtval((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pyR&scC@s$|j|j}dj|dS(Ns, i(RR7tjoin(RRR8((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pyRscC@s|j|j=dS(N(RR7(RR((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pyR'scC@s|j|jkS(N(R7R(RR((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pyt __contains__scC@st|t r$t|d r$tSt|t|sNt||}ntd|jDtd|jDkS(NR.cs@s'|]\}}|j|fVqdS(N(R7(t.0tktv((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pys scs@s'|]\}}|j|fVqdS(N(R7(R;R<R=((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pys s(R2RthasattrR"ttypetdictt itermerged(Rtother((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pyt__eq__s  cC@s|j| S(N(RC(RRB((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pyt__ne__scC@s t|jS(N(R R(R((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pyR(scc@s'x |jjD]}|dVqWdS(Ni(RR-(Rtvals((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pyR*scC@sGy||}Wn'tk r7||jkr3n|SX||=|SdS(sD.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(tKeyErrort_HTTPHeaderDict__marker(RRtdefaultR#((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pyRs cC@s#y ||=Wntk rnXdS(N(RF(RR((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pytdiscards  cC@sM|j}||g}|jj||}||k rI|j|ndS(sAdds 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(R7Rt setdefaulttappend(RRR8t key_lowertnew_valsRE((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pytadds   cO@s]t|dkr0tdjt|nt|dkrL|dnd}t|trx|jD]\}}|j||qnWnt|trx|D]}|j|||qWndt|drxR|j D]}|j|||qWn'x$|D]\}}|j||q Wx*|j D]\}}|j||q9WdS(sGeneric 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__ is9extend() takes at most 1 positional arguments ({0} given)iR.N(( R t TypeErrortformatR2Rt iteritemsRNRR>R.titems(RtargsR6RBRR8R#((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pyR4s" " cC@sKy|j|j}Wn%tk r>||jkr:gS|SX|dSdS(smReturns a list of all the values for the named field. Returns an empty list if the key doesn't exist.iN(RR7RFRG(RRRHRE((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pytgetlists cC@s#dt|jt|jfS(Ns%s(%s)(R?R R@RA(R((sD/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/_collections.pyt__repr__scC@s\xU|D]M}|j|}t|tr:t|}n|g||j|js    J