11import json
22import pathlib
3+ import re
34import sqlite3
45import sys
56from pathlib import Path
1415def check_artifacts (session : Session ) -> None :
1516 """Validate that all project artifacts are available and consistent"""
1617 if not_available := _missing_files (
17- {".lint.json" , ".lint. txt" , ".security.json" , ".coverage" }, PROJECT_CONFIG .root
18+ {".lint.txt" , ".security.json" , ".coverage" }, PROJECT_CONFIG .root
1819 ):
1920 print (f"not available: { not_available } " )
2021 sys .exit (1 )
2122
2223 error = False
23- if msg := _validate_lint_json (Path (PROJECT_CONFIG .root , ".lint.json" )):
24- print (f"error in [.lint.json]: { msg } " )
25- error = True
24+ if msg := _validate_lint_txt (Path (PROJECT_CONFIG .root , ".lint.txt" )):
25+ print (f"error in [.lint.txt]: { msg } " )
2626 if msg := _validate_security_json (Path (PROJECT_CONFIG .root , ".security.json" )):
2727 print (f"error in [.security.json]: { msg } " )
2828 error = True
@@ -38,6 +38,18 @@ def _missing_files(expected_files: set, directory: Path) -> set:
3838 return expected_files - files
3939
4040
41+ def _validate_lint_txt (file : Path ) -> str :
42+ try :
43+ content = file .read_text ()
44+ except FileNotFoundError as ex :
45+ return f"Could not find file { file } , details: { ex } "
46+ expr = re .compile (r"^Your code has been rated at (\d+.\d+)/.*" , re .MULTILINE )
47+ matches = expr .search (content )
48+ if not matches :
49+ return f"Could not find a rating"
50+ return ""
51+
52+
4153def _validate_lint_json (file : Path ) -> str :
4254 try :
4355 content = file .read_text ()
0 commit comments