Python click 模块,make_pass_decorator() 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用click.make_pass_decorator()

项目:linchpin    作者:CentOS-PaaS-SIG    | 项目源码 | 文件源码
def init(ctx):
    """
    Initializes a linchpin project, which generates an example PinFile, and
    creates the necessary directory structure for topologies and layouts.

    ctx: Context object defined by the click.make_pass_decorator method
    """

    pf_w_path = _get_pinfile_path(exists=False)

    try:
        # lpcli.lp_init(pf_w_path, targets) # TODO implement targets option
        lpcli.lp_init(pf_w_path)
    except LinchpinError as e:
        ctx.log_state(e)
        sys.exit(1)
项目:browserstacker    作者:Stranger6667    | 项目源码 | 文件源码
def browserstacker_command(func):
    """
    Shortcut to define command for BrowserStacker.
    """
    pass_decorator = click.make_pass_decorator(APIWrapper)
    return cli.command()(pass_decorator(func))
项目:click_cli_frontend    作者:iluxame    | 项目源码 | 文件源码
def context():
        """
        Configuration context holder
        """
        return click.make_pass_decorator(Context, ensure=True)
项目:edm2016    作者:Knewton    | 项目源码 | 文件源码
def __init__(self):
        self.options = []
        self.pass_state = click.make_pass_decorator(State, ensure=True)