Skip to content

Commit 5cabd41

Browse files
committed
Refactor HTML generation in build_packages_page.py to group packages by status and improve readability
1 parent ce5851f commit 5cabd41

2 files changed

Lines changed: 54 additions & 16 deletions

File tree

package_list.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ dsPUcopulaClient, PU copula based synthetic data generator, https://github.com/b
4949
dsQueryLibrary, OHDSI query library implementation package, https://github.com/sib-swiss/dsQueryLibrary,,
5050
dsRadiomics, Radiomics feature extraction and segmentation package, https://github.com/isglobal-brge/dsRadiomics,, development
5151
dsRadiomicsClient, Radiomics feature extraction and segmentation package, https://github.com/isglobal-brge/dsRadiomicsClient,, development
52-
dsROCrate, RO-Crate interface, https://github.com/FederatedMethods/dsROCrate, https://cran.r-project.org/package=dsROCrate,
52+
dsROCrate, RO-Crate interface, https://github.com/FederatedMethods/dsROCrate, https://cran.r-project.org/package=dsROCrate,development
5353
dsSurvival, Survival analysis package, https://github.com/neelsoumya/dsSurvival,, retired
5454
dsSurvivalClient, Survival analysis package, https://github.com/neelsoumya/dsSurvivalClient,, retired
5555
dsSurvival, Survival analysis package, https://github.com/datashield/dsSurvival,, production

web_pages/build_packages_page.py

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,39 +40,77 @@ def main(csv_file_path, html_file_path):
4040
html_file.write('<th>GitHub owner</th>')
4141
html_file.write('</tr>')
4242

43+
production_rows = ""
44+
development_rows = ""
45+
retired_rows = ""
46+
unknown_rows = ""
47+
4348
row_count = 0
4449
for row in reader:
4550
print(row)
4651
row_count += 1
47-
html_file.write('<tr>')
48-
html_file.write('<td>' + str(row_count) + '</td>') # Row number
52+
53+
this_row = '<tr>'
54+
#html_file.write('<tr>')
55+
#html_file.write('<td>' + str(row_count) + '</td>') # Row number
56+
this_row += '<td>' + str(row_count) + '</td>' # Row number
4957

5058
# Add GitHub link if available, otherwise just the name
5159
if len(row[5]) > 0:
52-
html_file.write('<td class="left"><a href="' + row[5] + '" target="blank">' + row[0] + '</a></td>') # GH repository link with name
60+
#html_file.write('<td class="left"><a href="' + row[5] + '" target="blank">' + row[0] + '</a></td>') # GH repository link with name
61+
this_row += '<td class="left"><a href="' + row[5] + '" target="blank">' + row[0] + '</a></td>' # GH repository link with name
5362
else:
54-
html_file.write('<td class="left">' + row[0] + '</td>')
63+
#html_file.write('<td class="left">' + row[0] + '</td>')
64+
this_row += '<td class="left">' + row[0] + '</td>'
5565

5666
# Description
5767
if len(row[1]) > 0:
58-
html_file.write('<td class="left">' + row[1] + '</td>') # Description
68+
#html_file.write('<td class="left">' + row[1] + '</td>') # Description
69+
this_row += '<td class="left">' + row[1] + '</td>' # Description
5970
else:
60-
html_file.write('<td></td>')
71+
#html_file.write('<td></td>')
72+
this_row += '<td></td>'
6173

6274
if len(row[2]) > 0:
63-
html_file.write('<td><a href="' + row[2] + '" target="blank">' + row[3] + '</a></td>') # CRAN link
75+
#html_file.write('<td><a href="' + row[2] + '" target="blank">' + row[3] + '</a></td>') # CRAN link
76+
this_row += '<td><a href="' + row[2] + '" target="blank">' + row[3] + '</a></td>' # CRAN link
6477
else:
65-
html_file.write('<td></td>')
78+
#html_file.write('<td></td>')
79+
this_row += '<td></td>'
6680

6781

6882
# html_file.write('<td>' + row[3] + '</td>') # CRAN version
69-
html_file.write('<td>' + row[4] + '</td>') # CRAN license
70-
html_file.write('<td>' + row[6] + '</td>') # GH last update
71-
html_file.write('<td>' + row[7] + '</td>') # GH version
72-
html_file.write('<td>' + row[8] + '</td>') # GH license
73-
html_file.write('<td class="left">' + row[9] + '</td>') # GH owner
74-
html_file.write('</tr>\n')
75-
83+
#html_file.write('<td>' + row[4] + '</td>') # CRAN license
84+
this_row += '<td>' + row[4] + '</td>'
85+
#html_file.write('<td>' + row[6] + '</td>') # GH last update
86+
this_row += '<td>' + row[6] + '</td>'
87+
#html_file.write('<td>' + row[7] + '</td>') # GH version
88+
this_row += '<td>' + row[7] + '</td>'
89+
#html_file.write('<td>' + row[8] + '</td>') # GH license
90+
this_row += '<td>' + row[8] + '</td>'
91+
#html_file.write('<td class="left">' + row[9] + '</td>') # GH owner
92+
this_row += '<td class="left">' + row[9] + '</td>'
93+
#html_file.write('</tr>\n')
94+
this_row += '</tr>\n'
95+
96+
if row[10].strip() == 'production':
97+
production_rows += this_row
98+
elif row[10].strip() == 'development':
99+
development_rows += this_row
100+
elif row[10].strip() == 'retired':
101+
retired_rows += this_row
102+
else:
103+
unknown_rows += this_row
104+
105+
# Build the table with the rows grouped by status
106+
html_file.write('<tr><td colspan="9">Production</td></tr>')
107+
html_file.write(production_rows)
108+
html_file.write('<tr><td colspan="9">Development</td></tr>')
109+
html_file.write(development_rows)
110+
html_file.write('<tr><td colspan="9">Retired</td></tr>')
111+
html_file.write(retired_rows)
112+
html_file.write('<tr><td colspan="9">Unknown</td></tr>')
113+
html_file.write(unknown_rows)
76114
html_file.write('</table>')
77115

78116
html_file.write('Generated on ' + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))

0 commit comments

Comments
 (0)