def match_anywhere(needles, haystack, ignore_case=False):
 regex_needle = (('.*' + '.*'.join(imap(re.escape, needles))) + '.*')
 regex_flags = ((re.IGNORECASE | re.UNICODE) if ignore_case else re.UNICODE)
 found = (lambda haystack: re.search(regex_needle, haystack.path, flags=regex_flags))
 return ifilter(found, haystack)

def match_anywhere ( needles , haystack , ignore_case = False ) : regex_needle = ( ( '.*' + '.*' . join ( imap ( re . escape , needles ) ) ) + '.*' ) regex_flags = ( ( re . IGNORECASE | re . UNICODE ) if ignore_case else re . UNICODE ) found = ( lambda haystack : re . search ( regex_needle , haystack . path , flags = regex_flags ) ) return ifilter ( found , haystack )
matches needles anywhere in the path as long as theyre in the same order .