File: //usr/lib/python3/dist-packages/click/__pycache__/decorators.cpython-38.pyc
U
L�[�+ � @ s� d dl Z d dlZd dlmZ ddlmZ ddlmZ ddlm Z ddl
mZ dd � Zd
d� Z
d$d
d�Zdd� Zd%dd�Zd&dd�Zdd� Zdd� Zdd� Zdd� Zdd� Zd'dd �Zd!d"� Zdd#lmZmZmZmZ dS )(� N��update_wrapper� )� iteritems)�_check_for_unicode_literals)�echo��get_current_contextc s � fdd�}t |� �S )z]Marks a callback as wanting to receive the current context
object as first argument.
c s � t � f| �|�S �Nr ��args�kwargs��f� �2/usr/lib/python3/dist-packages/click/decorators.py�new_func s zpass_context.<locals>.new_funcr �r r r r r �pass_context s r c s � fdd�}t |� �S )z�Similar to :func:`pass_context`, but only pass the object on the
context onwards (:attr:`Context.obj`). This is useful if that object
represents the state of a nested system.
c s � t � jf| �|�S r
)r �objr r r r r s zpass_obj.<locals>.new_funcr r r r r �pass_obj s r Fc s � �fdd�}|S )a. Given an object type this creates a decorator that will work
similar to :func:`pass_obj` but instead of passing the object of the
current context, it will find the innermost context of type
:func:`object_type`.
This generates a decorator that works roughly like this::
from functools import update_wrapper
def decorator(f):
@pass_context
def new_func(ctx, *args, **kwargs):
obj = ctx.find_object(object_type)
return ctx.invoke(f, obj, *args, **kwargs)
return update_wrapper(new_func, f)
return decorator
:param object_type: the type of the object to pass.
:param ensure: if set to `True`, a new object will be created and
remembered on the context if it's not there yet.
c s �� �fdd�}t |� �S )Nc sJ t � }� r|���}n
|���}|d kr6td�j ��|j�|f| �|�S )NzGManaged to invoke callback without a context object of type %r existing)r Z
ensure_objectZfind_object�RuntimeError�__name__Zinvoke)r r
�ctxr )�ensurer �object_typer r r 6 s
�z8make_pass_decorator.<locals>.decorator.<locals>.new_funcr r �r r r r � decorator5 s z&make_pass_decorator.<locals>.decoratorr )r r r r r r �make_pass_decorator s
r c C s� t | t�rtd��z| j}|�� | `W n tk
r@ g }Y nX |�d�}|d krtt�| �}t |t �r~|�
d�}n
t�|�}||d<