def eglob(path, exclude=None):
fi = itertools.chain.from_iterable<EOL>paths = list(fi(glob2.iglob(d) for d in expand_paths(path)))<EOL>if exclude:<EOL><INDENT>cached_regex = cached_regices.get(exclude, None)<EOL>if not cached_regex:<EOL><INDENT>cached_regex = cached_regices[exclude] = re.compile(exclude)<EOL><DEDENT>paths = [x for x in paths if not cached_regex.search(x)]<EOL><DEDENT>return paths<EOL>
Like glob.glob, but supports "/path/**/{a,b,c}.txt" lookup