MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / main

Function main

scripts/add-spdx-attribution.py:495–539  ·  view source on GitHub ↗

Parse arguments and run SPDX attribution on source files.

()

Source from the content-addressed store, hash-verified

493
494
495def main():
496 """Parse arguments and run SPDX attribution on source files."""
497 parser = argparse.ArgumentParser(
498 description="Add SPDX attribution headers to source files"
499 )
500 parser.add_argument(
501 "--dry-run",
502 action="store_true",
503 help="Show what would be done without making changes",
504 )
505 parser.add_argument(
506 "--file", type=str, help="Process a specific file instead of all source files"
507 )
508 parser.add_argument(
509 "--repo-root", type=str, default=".", help="Repository root directory"
510 )
511
512 args = parser.parse_args()
513
514 # Initialize the attributor
515 attributor = SPDXAttributor(args.repo_root, dry_run=args.dry_run)
516
517 if args.file:
518 # Process single file
519 file_path = Path(args.file)
520 if not file_path.exists():
521 print(f"Error: File {file_path} does not exist")
522 sys.exit(1)
523
524 attributor.process_file(file_path)
525 else:
526 # Process all source files
527 source_files = attributor.find_source_files()
528
529 if args.dry_run:
530 print(f"Found {len(source_files)} source files to process")
531 print("\nDry run - showing what would be done:\n")
532
533 success_count = 0
534 for file_path in source_files:
535 if attributor.process_file(file_path):
536 success_count += 1
537
538 if not args.dry_run:
539 print(f"\nProcessed {success_count}/{len(source_files)} files successfully")
540
541
542if __name__ == "__main__":

Callers 1

Calls 4

process_fileMethod · 0.95
find_source_filesMethod · 0.95
SPDXAttributorClass · 0.85
exitMethod · 0.45

Tested by

no test coverage detected