Skip to content
Myr

relative imports

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent efba606 · Browse files · 1 file+18 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+18 added−4 removed

  • other:+18 added−4 removed

1 file+18 added−4 removed

modified:requests/sessions.py+18 added-4 removed
7 unmodified lines
8requests (cookies, auth, proxies).910"""1112import requests.api12import cookielib1314from . import api15161718class Session(object):19 """A Requests session."""2018 __attrs__ = ['headers', 'cookies', 'auth', 'timeout', 'proxies']21 __attrs__ = ['headers', 'cookies', 'auth', 'timeout', 'proxies', 'hooks']222324 def __init__(self, **kwargs):25
10 unmodified lines
3637 def __repr__(self):38 return '<requests-client at 0x%x>' % (id(self))3940 def __enter__(self):41 return self4243 def __exit__(self, *args):44 # print args45 pass464748 def _map_api_methods(self):49 """Reads each available method from requests.api and decorates50 them with a wrapper, which inserts any instance-local attributes51 (from __attrs__) that have been set, combining them with **kwargs.
9 unmodified lines
61 return func(*args, **kwargs)62 return wrapper_func6364 # Map and decorate each function available in requests.api55 map(lambda fn: setattr(self, fn, pass_args(getattr(requests.api, fn))),56 requests.api.__all__)65 map(lambda fn: setattr(self, fn, pass_args(getattr(api, fn))),66 api.__all__)676869def session(**kwargs):70 """Returns a :class:`Session` for context-managment."""7172 return Session(**kwargs)