util.py 文件源码

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

项目:mendel 作者: sproutsocial 项目源码 文件源码
def lcd_task(task, cd_to):
    """
    wrap a function so that it will be
    executed in a specific directory on
    the host machine

    uses `fabric.api.lcd(dest)`

    the returned function will have the same
    __name__ and __doc__ as the input `task`


    :param task: the function to execute
    :param cd_to: the directory in which to execute
    :return: a function that will be executed in `cd_to`
    """
    def func(*args, **kwargs):
        with lcd(cd_to):
            task(*args, **kwargs)

    func.__name__ = task.__name__
    func.__doc__ = task.__doc__
    return func
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号