comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/site-packages/requests/hooks.py @ 68:5028fdace37b

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 16:23:26 -0400
parents
children
comparison
equal deleted inserted replaced
67:0e9998148a16 68:5028fdace37b
1 """
2 requests.hooks
3 ~~~~~~~~~~~~~~
4
5 This module provides the capabilities for the Requests hooks system.
6
7 Available hooks:
8
9 ``response``:
10 The response generated from a Request.
11 """
12 HOOKS = ["response"]
13
14
15 def default_hooks():
16 return {event: [] for event in HOOKS}
17
18
19 # TODO: response is the only one
20
21
22 def dispatch_hook(key, hooks, hook_data, **kwargs):
23 """Dispatches a hook dictionary on a given piece of data."""
24 hooks = hooks or {}
25 hooks = hooks.get(key)
26 if hooks:
27 if hasattr(hooks, "__call__"):
28 hooks = [hooks]
29 for hook in hooks:
30 _hook_data = hook(hook_data, **kwargs)
31 if _hook_data is not None:
32 hook_data = _hook_data
33 return hook_data