Coverage for requests.structures : 64%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*-
requests.structures ~~~~~~~~~~~~~~~~~~~
Data structures that power Requests.
"""
"""docstring for IteratorProxy""" self.i = i # self.i = chain.from_iterable(i)
return self.i
if hasattr(self.i, '__len__'): return len(self.i) if hasattr(self.i, 'len'): return self.i.len if hasattr(self.i, 'fileno'): return os.fstat(self.i.fileno()).st_size
return "".join(islice(self.i, None, n))
""" A case-insensitive ``dict``-like object.
Implements all methods and operations of ``collections.MutableMapping`` as well as dict's ``copy``. Also provides ``lower_items``.
All keys are expected to be strings. The structure remembers the case of the last key to be set, and ``iter(instance)``, ``keys()``, ``items()``, ``iterkeys()``, and ``iteritems()`` will contain case-sensitive keys. However, querying and contains testing is case insensitive:
cid = CaseInsensitiveDict() cid['Accept'] = 'application/json' cid['aCCEPT'] == 'application/json' # True list(cid) == ['Accept'] # True
For example, ``headers['content-encoding']`` will return the value of a ``'Content-Encoding'`` response header, regardless of how the header name was originally stored.
If the constructor, ``.update``, or equality comparison operations are given keys that have equal ``.lower()``s, the behavior is undefined.
"""
# Use the lowercased key for lookups, but store the actual # key alongside the value.
del self._store[key.lower()]
return len(self._store)
"""Like iteritems(), but with all lowercase keys.""" return ( (lowerkey, keyval[1]) for (lowerkey, keyval) in self._store.items() )
if isinstance(other, collections.Mapping): other = CaseInsensitiveDict(other) else: return NotImplemented # Compare insensitively return dict(self.lower_items()) == dict(other.lower_items())
# Copy is required
return str(dict(self.items()))
"""Dictionary lookup object."""
return '<lookup \'%s\'>' % (self.name)
# We allow fall-through here, so values default to None
return self.__dict__.get(key, None)
return self.__dict__.get(key, default) |