Return True or False depending on whether *path* is matched. If no match is found among the patterns in this matcher, then the value in self.fallback is returned (defaults to None).
(self, path)
| 136 | self._add(pattern, cmd) |
| 137 | |
| 138 | def match(self, path): |
| 139 | """Return True or False depending on whether *path* is matched. |
| 140 | |
| 141 | If no match is found among the patterns in this matcher, then the value |
| 142 | in self.fallback is returned (defaults to None). |
| 143 | |
| 144 | """ |
| 145 | path = normalize_path(path).lstrip("/") |
| 146 | # do a fast lookup for full path matches (note: we do not count such matches): |
| 147 | non_existent = object() |
| 148 | value = self._path_full_patterns.get(path, non_existent) |
| 149 | |
| 150 | if value is not non_existent: |
| 151 | # we have a full path match! |
| 152 | self.recurse_dir = command_recurses_dir(value) |
| 153 | return self.is_include_cmd[value] |
| 154 | |
| 155 | # this is the slow way, if we have many patterns in self._items: |
| 156 | for pattern, cmd in self._items: |
| 157 | if pattern.match(path, normalize=False): |
| 158 | self.recurse_dir = pattern.recurse_dir |
| 159 | return self.is_include_cmd[cmd] |
| 160 | |
| 161 | # by default we will recurse if there is no match |
| 162 | self.recurse_dir = self.recurse_dir_default |
| 163 | return self.fallback |
| 164 | |
| 165 | |
| 166 | def normalize_path(path): |