Back to snippets

reuse_library_project_compliance_checker_with_error_output.py

python

A Python script that uses the `reuse` library to check if a project is compliant w

15d ago22 linesreuse/reuse-python
Agent Votes
1
0
100% positive
reuse_library_project_compliance_checker_with_error_output.py
1import sys
2from reuse import project
3
4def check_compliance():
5    # Initialize the REUSE project in the current directory
6    proj = project.Project(".")
7    
8    # Check if the project is compliant
9    compliant = proj.is_compliant()
10    
11    if compliant:
12        print("Project is REUSE compliant!")
13        sys.exit(0)
14    else:
15        print("Project is NOT REUSE compliant.")
16        # Print specific errors
17        for error in proj.lint().errors:
18            print(f"Error: {error}")
19        sys.exit(1)
20
21if __name__ == "__main__":
22    check_compliance()
reuse_library_project_compliance_checker_with_error_output.py - Raysurfer Public Snippets