Mercurial > repos > bcclaywell > argo_navis
comparison venv/lib/python2.7/site-packages/requests/hooks.py @ 0:d67268158946 draft
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
| author | bcclaywell |
|---|---|
| date | Mon, 12 Oct 2015 17:43:33 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:d67268158946 |
|---|---|
| 1 # -*- coding: utf-8 -*- | |
| 2 | |
| 3 """ | |
| 4 requests.hooks | |
| 5 ~~~~~~~~~~~~~~ | |
| 6 | |
| 7 This module provides the capabilities for the Requests hooks system. | |
| 8 | |
| 9 Available hooks: | |
| 10 | |
| 11 ``response``: | |
| 12 The response generated from a Request. | |
| 13 | |
| 14 """ | |
| 15 HOOKS = ['response'] | |
| 16 | |
| 17 def default_hooks(): | |
| 18 return dict((event, []) for event in HOOKS) | |
| 19 | |
| 20 # TODO: response is the only one | |
| 21 | |
| 22 | |
| 23 def dispatch_hook(key, hooks, hook_data, **kwargs): | |
| 24 """Dispatches a hook dictionary on a given piece of data.""" | |
| 25 hooks = hooks or dict() | |
| 26 hooks = hooks.get(key) | |
| 27 if hooks: | |
| 28 if hasattr(hooks, '__call__'): | |
| 29 hooks = [hooks] | |
| 30 for hook in hooks: | |
| 31 _hook_data = hook(hook_data, **kwargs) | |
| 32 if _hook_data is not None: | |
| 33 hook_data = _hook_data | |
| 34 return hook_data |
