core.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:notifiers 作者: liiight 项目源码 文件源码
def notify(ctx, provider):
    """Send a notification to a passed provider.

    Data should be passed via a key=value input like so:

        notifiers notify pushover token=foo user=bar message=test

    """
    p = get_notifier(provider)
    data = {}
    for item in ctx.args:
        data.update([item.split('=')])
    if 'message' not in data:
        message = click.get_text_stream('stdin').read()
        if not message:
            raise click.ClickException(
                "'message' option is required. "
                "Either pass it explicitly or pipe into the command"
            )
        data['message'] = message

    rsp = p.notify(**data)
    rsp.raise_on_errors()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号