def _file_gen(dname, fmatch=bool, dmatch=None):
    if dmatch is not None and not dmatch(dname):
        return

    for path, dirlist, filelist in os.walk(dname):
        if dmatch is not None: # prune directories to search
            newdl = [d for d in dirlist if dmatch(d)]
            if len(newdl) != len(dirlist):
                dirlist[:] = newdl # replace contents of dirlist to cause pruning

        for name in [f for f in filelist if fmatch(f)]:
            yield join(path, name)
A generator returning files under the given directory, with optional
dataset/ETHPy150Open OpenMDAO/OpenMDAO/openmdao/util/file_util.py/_file_gen