Back to snippets
reuse_library_project_compliance_checker_with_error_output.py
pythonA Python script that uses the `reuse` library to check if a project is compliant w
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()