Process a single file to add SPDX attribution.
(self, file_path: Path)
| 429 | return False |
| 430 | |
| 431 | def process_file(self, file_path: Path) -> bool: |
| 432 | """Process a single file to add SPDX attribution.""" |
| 433 | # Convert to absolute path if it's relative |
| 434 | if not file_path.is_absolute(): |
| 435 | file_path = self.repo_root / file_path |
| 436 | |
| 437 | if self._is_excluded(file_path): |
| 438 | if self.dry_run: |
| 439 | print(f"Excluded: {file_path}") |
| 440 | return False |
| 441 | |
| 442 | # Analyze git blame |
| 443 | contributors = self._analyze_git_blame(file_path) |
| 444 | if not contributors: |
| 445 | print(f"No contributors found for {file_path}") |
| 446 | return False |
| 447 | |
| 448 | # Generate SPDX headers |
| 449 | headers = self._generate_spdx_headers(contributors) |
| 450 | |
| 451 | if self.dry_run: |
| 452 | print(f"\nFile: {file_path}") |
| 453 | print(f"Contributors: {len(contributors)}") |
| 454 | for header in headers: |
| 455 | print(f" {header}") |
| 456 | return True |
| 457 | |
| 458 | # Remove existing SPDX headers |
| 459 | self._remove_existing_spdx_headers(file_path) |
| 460 | |
| 461 | # Apply new headers with REUSE |
| 462 | success = self._apply_reuse_annotation(file_path, headers) |
| 463 | |
| 464 | if success: |
| 465 | print(f"✓ Updated: {file_path}") |
| 466 | else: |
| 467 | print(f"✗ Failed: {file_path}") |
| 468 | |
| 469 | return success |
| 470 | |
| 471 | def find_source_files(self) -> List[Path]: |
| 472 | """Find all source files that should be processed.""" |
no test coverage detected