| 171 | |
| 172 | |
| 173 | class FNMatcher: |
| 174 | def __init__(self, pattern): |
| 175 | self.pattern = pattern |
| 176 | |
| 177 | def __call__(self, path): |
| 178 | pattern = self.pattern |
| 179 | |
| 180 | if ( |
| 181 | pattern.find(path.sep) == -1 |
| 182 | and iswin32 |
| 183 | and pattern.find(posixpath.sep) != -1 |
| 184 | ): |
| 185 | # Running on Windows, the pattern has no Windows path separators, |
| 186 | # and the pattern has one or more Posix path separators. Replace |
| 187 | # the Posix path separators with the Windows path separator. |
| 188 | pattern = pattern.replace(posixpath.sep, path.sep) |
| 189 | |
| 190 | if pattern.find(path.sep) == -1: |
| 191 | name = path.basename |
| 192 | else: |
| 193 | name = str(path) # path.strpath # XXX svn? |
| 194 | if not os.path.isabs(pattern): |
| 195 | pattern = "*" + path.sep + pattern |
| 196 | return fnmatch.fnmatch(name, pattern) |
| 197 | |
| 198 | |
| 199 | def map_as_list(func, iter): |