librispeech.py 文件源码

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

项目:ngraph 作者: NervanaSystems 项目源码 文件源码
def get_files(directory, pattern, recursive=True):
    """ Return the full path to all files in directory matching the specified
    pattern.

    Arguments:
        directory (str): Directory path in which to look
        pattern (str): A glob pattern for filenames
        recursive (bool): Searches recursively if True

    Returns:
        A list of matching file paths
    """

    # This yields an iterator which really speeds up looking through large, flat directories
    if recursive is False:
        it = glob.iglob(os.path.join(directory, pattern))
        return it

    # If we want to recurse, use os.walk instead
    matches = list()
    for root, dirnames, filenames in os.walk(directory):
        matches.extend([os.path.join(root, ss) for ss in
                        fnmatch.filter(filenames, pattern)])

    return matches
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号