Home / File/ hooks.py — requests Source File

hooks.py — requests Source File

Architecture documentation for hooks.py, a python file in the requests codebase. 0 imports, 2 dependents.

File python CoreAPI SessionLifecycle 2 dependents 2 functions

Entity Profile

Dependency Diagram

graph LR
  06c77466_ae83_6ca8_4f12_f6a21fba9313["hooks.py"]
  461bc6e0_32e7_8eab_ec87_7226e7be0d13["models.py"]
  461bc6e0_32e7_8eab_ec87_7226e7be0d13 --> 06c77466_ae83_6ca8_4f12_f6a21fba9313
  ea1101aa_233b_1206_7b38_a38f0fe92a52["sessions.py"]
  ea1101aa_233b_1206_7b38_a38f0fe92a52 --> 06c77466_ae83_6ca8_4f12_f6a21fba9313
  style 06c77466_ae83_6ca8_4f12_f6a21fba9313 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""
requests.hooks
~~~~~~~~~~~~~~

This module provides the capabilities for the Requests hooks system.

Available hooks:

``response``:
    The response generated from a Request.
"""

HOOKS = ["response"]


def default_hooks():
    return {event: [] for event in HOOKS}


# TODO: response is the only one


def dispatch_hook(key, hooks, hook_data, **kwargs):
    """Dispatches a hook dictionary on a given piece of data."""
    hooks = hooks or {}
    hooks = hooks.get(key)
    if hooks:
        if hasattr(hooks, "__call__"):
            hooks = [hooks]
        for hook in hooks:
            _hook_data = hook(hook_data, **kwargs)
            if _hook_data is not None:
                hook_data = _hook_data
    return hook_data

Domain

Subdomains

Frequently Asked Questions

What does hooks.py do?
hooks.py is a source file in the requests codebase, written in python. It belongs to the CoreAPI domain, SessionLifecycle subdomain.
What functions are defined in hooks.py?
hooks.py defines 2 function(s): default_hooks, dispatch_hook.
What files import hooks.py?
hooks.py is imported by 2 file(s): models.py, sessions.py.
Where is hooks.py in the architecture?
hooks.py is located at src/requests/hooks.py (domain: CoreAPI, subdomain: SessionLifecycle, directory: src/requests).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free