Eric Snow | e4c431e | 2019-10-18 19:00:04 -0700 | [diff] [blame] | 1 | from c_analyzer.common.files import ( |
| 2 | C_SOURCE_SUFFIXES, walk_tree, iter_files_by_suffix, |
| 3 | ) |
| 4 | |
| 5 | from . import SOURCE_DIRS, REPO_ROOT |
| 6 | |
| 7 | # XXX need tests: |
| 8 | # * iter_files() |
| 9 | |
| 10 | |
| 11 | def iter_files(*, |
| 12 | walk=walk_tree, |
| 13 | _files=iter_files_by_suffix, |
| 14 | ): |
| 15 | """Yield each file in the tree for each of the given directory names.""" |
| 16 | excludedtrees = [ |
| 17 | os.path.join('Include', 'cpython', ''), |
| 18 | ] |
| 19 | def is_excluded(filename): |
| 20 | for root in excludedtrees: |
| 21 | if filename.startswith(root): |
| 22 | return True |
| 23 | return False |
| 24 | for filename in _files(SOURCE_DIRS, C_SOURCE_SUFFIXES, REPO_ROOT, |
| 25 | walk=walk, |
| 26 | ): |
| 27 | if is_excluded(filename): |
| 28 | continue |
| 29 | yield filename |