pyrate.py 文件源码

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

项目:pyrate-build 作者: pyrate-build 项目源码 文件源码
def match(value, dn, recurse):
    import fnmatch
    result = []
    if recurse:
        walk_entries = os.walk(dn)
    else:
        walk_entries = [(dn, [], os.listdir(dn))]
    for walk_result in walk_entries:
        for fn in walk_result[2]:
            fn = os.path.relpath(os.path.join(walk_result[0], fn), dn)
            accept = False
            for token in value.split():
                negate = token.startswith('-')
                if negate:
                    token = token[1:]
                if not fnmatch.fnmatch(fn, token):
                    continue
                accept = not negate
            if accept:
                result.append(fn)
    result.sort()
    return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号