Given a root directory path and a list of .dockerignore patterns, return an iterator of all paths (both regular files and directories) in the root directory that do *not* match any of the patterns. All paths returned are relative to the root.
(root, patterns, dockerfile=None)
| 39 | |
| 40 | |
| 41 | def exclude_paths(root, patterns, dockerfile=None): |
| 42 | """ |
| 43 | Given a root directory path and a list of .dockerignore patterns, return |
| 44 | an iterator of all paths (both regular files and directories) in the root |
| 45 | directory that do *not* match any of the patterns. |
| 46 | |
| 47 | All paths returned are relative to the root. |
| 48 | """ |
| 49 | |
| 50 | if dockerfile is None: |
| 51 | dockerfile = 'Dockerfile' |
| 52 | |
| 53 | patterns.append(f"!{dockerfile}") |
| 54 | pm = PatternMatcher(patterns) |
| 55 | return set(pm.walk(root)) |
| 56 | |
| 57 | |
| 58 | def build_file_list(root): |