ruạṛ
a [��f�$ � @ s\ d Z ddlmZ ddlZddlmZ ddlmZ dd� Zdd � Z d d� Z dd � Zdd� ZdS )zHook decorators.� )�wrapsN)�COMBINED_METHODS)�get_argnamesc s � ��fdd�}|S )a� Decorator to execute the given action function *before* the responder. Args: action (callable): A function of the form ``func(req, resp, resource, params)``, where `resource` is a reference to the resource class instance associated with the request, and `params` is a dict of URI Template field names, if any, that will be passed into the resource responder as kwargs. Note: Hooks may inject extra params as needed. For example:: def do_something(req, resp, resource, params): try: params['id'] = int(params['id']) except ValueError: raise falcon.HTTPBadRequest('Invalid ID', 'ID was not valid.') params['answer'] = 42 *args: Any additional arguments will be passed to *action* in the order given, immediately following the *req*, *resp*, *resource*, and *params* arguments. **kwargs: Any additional keyword arguments will be passed through to *action*. c s� t | tj�rr| � tD ]X}d|�� �zt� ��}W n tyD Y q0 t|�r|f���� �fdd� }|� q� S | }t|����}|S d S )N�on_c s t | � ���}t��|� d S �N)�_wrap_with_before�setattr)� responder� do_before_all��action�args�kwargs�resource�responder_name� �p/sparta/input/_build_configuration/image_build+validate/lib/bmcenv/lib64/python3.9/site-packages/falcon/hooks.py�letL s z$before.<locals>._before.<locals>.let) � isinstance�six�class_typesr �lower�getattr�AttributeError�callabler )�responder_or_resource�methodr r � do_before_one�r r r �r r r �_before8 s zbefore.<locals>._beforer )r r r r r r r �before s #r! c s � ��fdd�}|S )aF Decorator to execute the given action function *after* the responder. Args: action (callable): A function of the form ``func(req, resp, resource)``, where `resource` is a reference to the resource class instance associated with the request *args: Any additional arguments will be passed to *action* in the order given, immediately following the *req*, *resp*, *resource*, and *params* arguments. **kwargs: Any additional keyword arguments will be passed through to *action*. c s� t | tj�rr| � tD ]X}d|�� �zt� ��}W n tyD Y q0 t|�r|f���� �fdd� }|� q� S | }t|����}|S d S )Nr c s t | � ���}t��|� d S r )�_wrap_with_afterr )r �do_after_allr r r r s z"after.<locals>._after.<locals>.let) r r r r r r r r r"