1+ import streamlit as st
12from services .db import DbClient
23from tqdm import tqdm
34
@@ -6,9 +7,8 @@ def add_new_line(summary):
67 return summary .replace ("\n " , "<br>" )
78
89
9- if __name__ == "__main__" :
10- with open ("./private/report.html" , "w" , newline = "" , encoding = "utf-8" ) as f :
11- f .write ("""
10+ def make_a_report ():
11+ st .html ("""
1212 <html>
1313 <head>
1414 <meta charset="utf-8">
@@ -27,35 +27,35 @@ def add_new_line(summary):
2727 "SELECT COUNT(*) FROM Requirements"
2828 ).fetchone ()[0 ]
2929
30- f . write ('<nav style="break-after: page;"><h1>Table of Contents</h1><ul>' )
30+ st . html ('<nav style="break-after: page;"><h1>Table of Contents</h1><ul>' )
3131
3232 for requirement in tqdm (
33- db .conn .execute ("SELECT * FROM Requirements" ).fetchall (),
34- desc = "Generating table of contents" ,
35- unit = "requirements" ,
36- total = all_reqs_count ,
33+ db .conn .execute ("SELECT * FROM Requirements" ).fetchall (),
34+ desc = "Generating table of contents" ,
35+ unit = "requirements" ,
36+ total = all_reqs_count ,
3737 ):
3838 req_id , req_external_id , req_summary , _ = requirement
39- f . write (f"""
39+ st . html (f"""
4040 <li>
4141 <a href="#req_{ req_id } ">
4242 Requirement { req_external_id } ({ req_id } )
4343 </a>
4444 </li>""" )
4545
46- f . write ("</ul></nav>" )
46+ st . html ("</ul></nav>" )
4747
4848 data = db .conn .execute ("""
4949 SELECT
5050 Requirements.id as req_id,
5151 Requirements.external_id as req_external_id,
5252 Requirements.summary as req_summary,
53-
53+
5454 Annotations.id as anno_id,
5555 Annotations.summary as anno_summary,
56-
56+
5757 AnnotationsToRequirements.cached_distance as distance,
58-
58+
5959 TestCases.id as case_id,
6060 TestCases.test_script as test_script,
6161 TestCases.test_case as test_case
@@ -83,22 +83,22 @@ def write_requirement():
8383 # if written_count > 5:
8484 # return
8585 written_count += 1
86- f . write (f"""
86+ st . html (f"""
8787 <section style="break-after: page;">
8888 <h2 id="req_{ current_req_id } ">Requirement { current_req_external_id } ({ current_req_id } )</h2>
8989 <p>{ add_new_line (req_summary )} </p>
9090 <h3>Annotations</h3>
9191 <ul>
9292 """ )
9393 for anno_id , (anno_summary , distance ) in current_annotations .items ():
94- f . write (
94+ st . html (
9595 f"<li>Annotation { anno_id } (distance: { distance :.3f} ): <p>{ add_new_line (anno_summary )} </p></li>"
9696 )
97- f . write ("</ul>" )
98- f . write ("<h3>Test Scripts</h3><ul>" )
97+ st . html ("</ul>" )
98+ st . html ("<h3>Test Scripts</h3><ul>" )
9999 for test_script in current_test_scripts :
100- f . write (f"<li>{ test_script } </li>" )
101- f . write ("</ul></section>" )
100+ st . html (f"<li>{ test_script } </li>" )
101+ st . html ("</ul></section>" )
102102
103103 for row in data .fetchall ():
104104 (
@@ -123,9 +123,10 @@ def write_requirement():
123123 current_annotations [anno_id ] = (anno_summary , distance )
124124 current_test_scripts .add (test_script )
125125 write_requirement ()
126- f . write ("""
126+ st . html ("""
127127 </article>
128128 </main>
129129 </body>
130130 </html>
131131 """ )
132+
0 commit comments