filegardener.py 文件源码

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

项目:filegardener 作者: smorin 项目源码 文件源码
def onlycopy(ctx, srcdir, srcfile, checkdir, relpath, failonerror, include_regex, include_src_regex, include_dst_regex):
    """
    onlycopy command prints list of all the files that aren't in the srcdir
    """

    if not (srcdir or srcfile):
        raise click.BadOptionUsage("The regex didn't compile. For correct usage"
                                   " see:  https://docs.python.org/2/library/re.html")
    # validate the regex options
    check_regex(include_regex)
    if include_regex is not None:
        include_src_regex = include_regex
        include_dst_regex = include_regex
    check_regex(include_src_regex)
    check_regex(include_dst_regex)

    if relpath:
        basepath = os.getcwd()
        for i in onlycopy_yield(srcdir, checkdir, failonerror, src_regex=include_src_regex, dst_regex=include_dst_regex,
                                srcfile=srcfile):
            click.echo(os.path.relpath(i, basepath))
    else:
        for i in onlycopy_yield(srcdir, checkdir, failonerror, src_regex=include_src_regex, dst_regex=include_dst_regex,
                                srcfile=srcfile):
            click.echo(i)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号