#NEWLINE# def filter( names , pat ) : #NEWLINE# #INDENT# 'Return the subset of the list NAMES that match PAT' #NEWLINE# import os , posixpath #NEWLINE# result = [ ] #NEWLINE# pat = os . path . normcase ( pat ) #NEWLINE# if ( not ( pat in _cache ) ) : #NEWLINE# #INDENT# res = translate ( pat ) #NEWLINE# _cache [ pat ] = re . compile ( res ) #NEWLINE# #UNINDENT# match = _cache [ pat ] . match #NEWLINE# if ( os . path is posixpath ) : #NEWLINE# #INDENT# for name in names : #NEWLINE# #INDENT# if match ( name ) : #NEWLINE# #INDENT# result . append ( name ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# for name in names : #NEWLINE# #INDENT# if match ( os . path . normcase ( name ) ) : #NEWLINE# #INDENT# result . append ( name ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return result