Talk the directory.
(entry)
| 19 | |
| 20 | |
| 21 | def walk_directory(entry): |
| 22 | """Talk the directory.""" |
| 23 | |
| 24 | if "header" not in entry: |
| 25 | raise ValueError("Current entry does not have a header.") |
| 26 | if "include" not in entry: |
| 27 | raise ValueError("Current entry does not have an include list.") |
| 28 | |
| 29 | def _list_include(): |
| 30 | """List all files specified in the include list.""" |
| 31 | for include_pattern in entry["include"]: |
| 32 | yield from glob.iglob(include_pattern, recursive=True) |
| 33 | |
| 34 | def _filter_exclude(iterable): |
| 35 | """Filter filenames from an iterator by the exclude patterns.""" |
| 36 | for filename in iterable: |
| 37 | for exclude_pattern in entry.get("exclude", []): |
| 38 | if fnmatch.fnmatch(filename, exclude_pattern): |
| 39 | break |
| 40 | else: |
| 41 | yield filename |
| 42 | |
| 43 | files = _filter_exclude(set(_list_include())) |
| 44 | return list(files) |
| 45 | |
| 46 | |
| 47 | def main(input_file="NOTICE.yml"): |
no test coverage detected