2
2
import sys
3
3
from pathlib import Path
4
4
5
+
5
6
def html_escape (text ):
6
7
return (text or "" ).replace ("&" , "&" ).replace ("<" , "<" ).replace (">" , ">" )
7
8
9
+
8
10
def render_schema (schema_name , schema ):
9
11
html = f'<details><summary><b>{ html_escape (schema_name )} </b> '
10
12
html += f'({ schema .get ("covered_properties" , 0 )} /{ schema .get ("total_properties" , 0 )} couvertes)'
@@ -18,15 +20,17 @@ def render_schema(schema_name, schema):
18
20
if schema .get ("missing_properties" ):
19
21
html += '<li><b>Manquantes:</b> ' + ", " .join (html_escape (p ) for p in schema ["missing_properties" ]) + '</li>'
20
22
html += '</ul></details>\n '
23
+
21
24
return html
22
25
26
+
23
27
def main ():
24
28
input_path = Path ("coverage-report.json" )
25
29
output_path = Path ("coverage-report.html" )
26
30
if not input_path .exists ():
27
31
print ("coverage-report.json non trouvé." )
28
32
sys .exit (1 )
29
- with open (input_path , "r" ) as f :
33
+ with open (input_path , "r" , encoding = "utf-8" ) as f :
30
34
data = json .load (f )
31
35
32
36
html = [
@@ -47,7 +51,7 @@ def main():
47
51
schema_analysis = data .get ("schema_analysis" , {})
48
52
schema_details = schema_analysis .get ("schema_details" , {})
49
53
html .append ("<h2>Couverture des schémas</h2>" )
50
- html .append (f"<p>Schémas couverts : { schema_analysis .get ('covered_schemas' ,0 )} / { schema_analysis .get ('total_schemas' ,0 )} </p>" )
54
+ html .append (f"<p>Schémas couverts : { schema_analysis .get ('covered_schemas' , 0 )} / { schema_analysis .get ('total_schemas' ,0 )} </p>" )
51
55
html .append ("<div>" )
52
56
for schema_name , schema in sorted (schema_details .items ()):
53
57
html .append (render_schema (schema_name , schema ))
@@ -57,5 +61,6 @@ def main():
57
61
output_path .write_text ("\n " .join (html ), encoding = "utf-8" )
58
62
print (f"Rapport HTML généré : { output_path } " )
59
63
64
+
60
65
if __name__ == "__main__" :
61
- main ()
66
+ main ()
0 commit comments