Check if the directory is in the exclude list. Note: by having trailing slashes, we avoid common prefix issues, like e.g. an exlude "foo" also accidentally excluding "foobar".
(root, excludes)
| 176 | |
| 177 | |
| 178 | def is_excluded(root, excludes): |
| 179 | """ |
| 180 | Check if the directory is in the exclude list. |
| 181 | |
| 182 | Note: by having trailing slashes, we avoid common prefix issues, like |
| 183 | e.g. an exlude "foo" also accidentally excluding "foobar". |
| 184 | """ |
| 185 | sep = path.sep |
| 186 | if not root.endswith(sep): |
| 187 | root += sep |
| 188 | for exclude in excludes: |
| 189 | if root.startswith(exclude): |
| 190 | return True |
| 191 | return False |
| 192 | |
| 193 | |
| 194 | def main2(argv=sys.argv): |