Find all Python files Args: root_dir: Root directory exclude_patterns: Directory patterns to exclude Returns: List of Python file paths
(root_dir: str, exclude_patterns: List[str] = None)
| 211 | |
| 212 | |
| 213 | def find_python_files(root_dir: str, exclude_patterns: List[str] = None) -> List[str]: |
| 214 | """ |
| 215 | Find all Python files |
| 216 | |
| 217 | Args: |
| 218 | root_dir: Root directory |
| 219 | exclude_patterns: Directory patterns to exclude |
| 220 | |
| 221 | Returns: |
| 222 | List of Python file paths |
| 223 | """ |
| 224 | if exclude_patterns is None: |
| 225 | exclude_patterns = ['venv', '.venv', 'node_modules', '__pycache__', '.git', 'build', 'dist', '.eggs'] |
| 226 | |
| 227 | python_files = [] |
| 228 | |
| 229 | for root, dirs, files in os.walk(root_dir): |
| 230 | # Exclude specific directories |
| 231 | dirs[:] = [d for d in dirs if d not in exclude_patterns and not d.startswith('.')] |
| 232 | |
| 233 | for file in files: |
| 234 | if file.endswith('.py'): |
| 235 | python_files.append(os.path.join(root, file)) |
| 236 | |
| 237 | return sorted(python_files) |
| 238 | |
| 239 | |
| 240 | def main(): |