Yields the absolute paths of files found within the given start
    directory. Can optionally filter paths using a regex pattern.

def walkfiles(startdir, regex=None, recurse=True):
    """Yields the absolute paths of files found within the given start
    directory. Can optionally filter paths using a regex pattern."""
    for r,_,fs in os.walk(startdir):
        if not recurse and startdir != r:
            return
        for f in fs:
            path = op.abspath(op.join(r,f))
            if regex and not _is_match(regex, path):
                    continue
            if op.isfile(path):
                yield path