blendfile_pack.py 文件源码

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

项目:bpy_lambda 作者: bcongdon 项目源码 文件源码
def exclusion_filter(exclude: str):
    """Converts a filter string "*.abc;*.def" to a function that can be passed to pack().

    If 'exclude' is None or an empty string, returns None (which means "no filtering").
    """

    if not exclude:
        return None

    import re
    import fnmatch

    # convert string into regex callback that operates on bytes
    # "*.txt;*.png;*.rst" --> rb".*\.txt$|.*\.png$|.*\.rst$"
    pattern = b'|'.join(fnmatch.translate(f).encode('utf-8')
                        for f in exclude.split(';')
                        if f)
    compiled_pattern = re.compile(pattern, re.IGNORECASE)

    def filename_filter(fname: bytes):
        return not compiled_pattern.match(fname)

    return filename_filter
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号