Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: swarm_client/third_party/requests/hooks.py

Issue 69143004: Delete swarm_client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
16
17 HOOKS = ['response']
18
19
20 def default_hooks():
21 hooks = {}
22 for event in HOOKS:
23 hooks[event] = []
24 return hooks
25
26 # TODO: response is the only one
27
28
29 def dispatch_hook(key, hooks, hook_data, **kwargs):
30 """Dispatches a hook dictionary on a given piece of data."""
31
32 hooks = hooks or dict()
33
34 if key in hooks:
35 hooks = hooks.get(key)
36
37 if hasattr(hooks, '__call__'):
38 hooks = [hooks]
39
40 for hook in hooks:
41 _hook_data = hook(hook_data, **kwargs)
42 if _hook_data is not None:
43 hook_data = _hook_data
44
45 return hook_data
OLDNEW
« no previous file with comments | « swarm_client/third_party/requests/exceptions.py ('k') | swarm_client/third_party/requests/models.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698