def filter(names, pat):
import os<EOL>result=[]<EOL>try:<EOL><INDENT>re_pat = _cache[pat]<EOL><DEDENT>except KeyError:<EOL><INDENT>res = translate(pat)<EOL>if len(_cache) >= _MAXCACHE:<EOL><INDENT>globals()['<STR_LIT>'] = {}<EOL><DEDENT>_cache[pat] = re_pat = re.compile(res)<EOL><DEDENT>match = re_pat.match<EOL>if <NUM_LIT:1>:<EOL><INDENT>for name in names:<EOL><INDENT>if match(name):<EOL><INDENT>result.append(name)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>for name in names:<EOL><INDENT>if match(os.path.normcase(name)):<EOL><INDENT>result.append(name)<EOL><DEDENT><DEDENT><DEDENT>return result<EOL>
Return the subset of the list NAMES that match PAT