Construct a list from those elements of the iterable NAMES that match PAT.
(names, pat)
| 51 | |
| 52 | |
| 53 | def filter(names, pat): |
| 54 | """Construct a list from those elements of the iterable NAMES that match PAT.""" |
| 55 | result = [] |
| 56 | pat = os.path.normcase(pat) |
| 57 | match = _compile_pattern(pat) |
| 58 | if os.path is posixpath: |
| 59 | # normcase on posix is NOP. Optimize it away from the loop. |
| 60 | for name in names: |
| 61 | if match(name): |
| 62 | result.append(name) |
| 63 | else: |
| 64 | for name in names: |
| 65 | if match(os.path.normcase(name)): |
| 66 | result.append(name) |
| 67 | return result |
| 68 | |
| 69 | |
| 70 | def filterfalse(names, pat): |
searching dependent graphs…