some refactoring

Signed-off-by: Ganyu (Bruce) Xu <g66xu@uwaterloo.ca>
This commit is contained in:
Ganyu (Bruce) Xu 2025-09-24 17:38:30 -04:00
parent c52e0f42c3
commit 606ef108c6
2 changed files with 11 additions and 10 deletions

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
from collections import namedtuple
import os import os
import tabulate import tabulate
@ -15,6 +14,7 @@ ALG_SUPPORT_HEADER = [
] ]
COMMIT_HASH_LEN = 7 COMMIT_HASH_LEN = 7
def format_upstream_source(source: str) -> str: def format_upstream_source(source: str) -> str:
"""For each YAML data sheet, the primary-upstream.source field contains some """For each YAML data sheet, the primary-upstream.source field contains some
URL to the implementation. At this moment all URLs are links to GitHub, so URL to the implementation. At this moment all URLs are links to GitHub, so
@ -38,6 +38,7 @@ def format_upstream_source(source: str) -> str:
output += f"@{commit}" output += f"@{commit}"
return f"[{output}]({url})" return f"[{output}]({url})"
def render_alg_support_tbl(doc_dir: str) -> str: def render_alg_support_tbl(doc_dir: str) -> str:
"""Render a markdown table summarizing the algorithms described by YAML data """Render a markdown table summarizing the algorithms described by YAML data
sheets stored in the specified doc directory sheets stored in the specified doc directory
@ -62,11 +63,13 @@ def render_alg_support_tbl(doc_dir: str) -> str:
std_status = algdata["standardization-status"] std_status = algdata["standardization-status"]
# TODO: unsure what to do with spec-url for now # TODO: unsure what to do with spec-url for now
primary_impl = format_upstream_source(algdata["primary-upstream"]["source"]) primary_impl = format_upstream_source(algdata["primary-upstream"]["source"])
rows.append([ rows.append(
[
f"[{alg_name}]({md_url})", f"[{alg_name}]({md_url})",
std_status, std_status,
primary_impl, primary_impl,
]) ]
)
tbl = tabulate.tabulate(rows, tablefmt="pipe", headers="firstrow") tbl = tabulate.tabulate(rows, tablefmt="pipe", headers="firstrow")
return tbl return tbl

View File

@ -342,8 +342,6 @@ def do_it(liboqs_root):
out_md.write(tabulate.tabulate(table, tablefmt="pipe", headers="firstrow", colalign=("center",))) out_md.write(tabulate.tabulate(table, tablefmt="pipe", headers="firstrow", colalign=("center",)))
out_md.write('\n') out_md.write('\n')
# TODO:construct the algorithm support table, replace the appropriate
# section in README.md (OQS_TEMPLATE_FRAGMENT_ALG_SUPPORT_START)
update_readme(liboqs_root) update_readme(liboqs_root)