|
19 | 19 | from collections import defaultdict
|
20 | 20 | import re
|
21 | 21 |
|
22 |
| -# Folders to exclude from processing (can be extended as needed) |
| 22 | +# Folders to exclude from processing |
23 | 23 | EXCLUDED_FOLDERS = {'.kiro', '.git', 'node_modules', '__pycache__'}
|
24 | 24 |
|
25 | 25 |
|
26 |
| -def apply_folder_exclusion_patches(): |
27 |
| - """ |
28 |
| - Apply patches to exclude specified folders from processing. |
29 |
| - This integrates folder exclusion as a core feature. |
30 |
| - """ |
| 26 | +def _configure_folder_exclusion(): |
| 27 | + """Configure file processing to exclude specified folders.""" |
31 | 28 | from aws_doc_sdk_examples_tools import file_utils, validator_config
|
32 | 29 | from aws_doc_sdk_examples_tools.fs import Fs, PathFs
|
33 | 30 |
|
34 |
| - def patched_skip(path: Path) -> bool: |
35 |
| - """Enhanced skip function that ignores specified folders.""" |
| 31 | + def enhanced_skip(path: Path) -> bool: |
| 32 | + """Skip function that ignores excluded folders and standard ignored files.""" |
36 | 33 | # Check if path contains any excluded folders
|
37 | 34 | if any(excluded_folder in path.parts for excluded_folder in EXCLUDED_FOLDERS):
|
38 | 35 | return True
|
39 | 36 |
|
40 |
| - # Call original skip logic |
| 37 | + # Apply standard skip logic |
41 | 38 | return path.suffix.lower() not in validator_config.EXT_LOOKUP or path.name in validator_config.IGNORE_FILES
|
42 | 39 |
|
43 |
| - def patched_get_files( |
| 40 | + def enhanced_get_files( |
44 | 41 | root: Path, skip: Callable[[Path], bool] = lambda _: False, fs: Fs = PathFs()
|
45 | 42 | ) -> Generator[Path, None, None]:
|
46 |
| - """Enhanced get_files that uses our patched skip function.""" |
| 43 | + """Get files using enhanced skip function.""" |
47 | 44 | for path in file_utils.walk_with_gitignore(root, fs=fs):
|
48 |
| - if not patched_skip(path): |
| 45 | + if not enhanced_skip(path): |
49 | 46 | yield path
|
50 | 47 |
|
51 |
| - # Apply the patches |
52 |
| - validator_config.skip = patched_skip |
53 |
| - file_utils.get_files = patched_get_files |
| 48 | + # Configure the file processing functions |
| 49 | + validator_config.skip = enhanced_skip |
| 50 | + file_utils.get_files = enhanced_get_files |
54 | 51 |
|
55 | 52 | excluded_list = ', '.join(sorted(EXCLUDED_FOLDERS))
|
56 |
| - print(f"Applied folder exclusion: {excluded_list} folders excluded") |
| 53 | + print(f"Folder exclusion configured: {excluded_list} folders excluded") |
57 | 54 |
|
58 | 55 |
|
59 |
| -# Apply folder exclusion patches when module is imported |
60 |
| -apply_folder_exclusion_patches() |
| 56 | +# Configure folder exclusion when module is imported |
| 57 | +_configure_folder_exclusion() |
61 | 58 |
|
62 | 59 |
|
63 | 60 | # Default to not using Rich
|
|
0 commit comments