From 606ef108c62a3bf2999b8d9afbce60d8c1abbd10 Mon Sep 17 00:00:00 2001 From: "Ganyu (Bruce) Xu" Date: Wed, 24 Sep 2025 17:38:30 -0400 Subject: [PATCH] some refactoring Signed-off-by: Ganyu (Bruce) Xu --- scripts/update_alg_support_table.py | 19 +++++++++++-------- scripts/update_docs_from_yaml.py | 2 -- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/scripts/update_alg_support_table.py b/scripts/update_alg_support_table.py index 0a38ab984..1dd41aedf 100644 --- a/scripts/update_alg_support_table.py +++ b/scripts/update_alg_support_table.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: MIT -from collections import namedtuple import os import tabulate @@ -15,6 +14,7 @@ ALG_SUPPORT_HEADER = [ ] COMMIT_HASH_LEN = 7 + def format_upstream_source(source: str) -> str: """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 @@ -24,13 +24,13 @@ def format_upstream_source(source: str) -> str: / otherwise with a link to the repository """ - prefix = "https://github.com/" + prefix = "https://github.com/" if not prefix in source: raise ValueError(f"Non-GitHub source {source}") url_start = source.find(prefix) url = source[url_start:].split(" ")[0] # example: ["PQClean", "PQClean", "commit", "1eacfdaf..."] - tokens = url[len(prefix):].split("/") + tokens = url[len(prefix) :].split("/") handle, repo = tokens[0], tokens[1] output = f"{handle}/{repo}" if "commit/" in url: @@ -38,6 +38,7 @@ def format_upstream_source(source: str) -> str: output += f"@{commit}" return f"[{output}]({url})" + def render_alg_support_tbl(doc_dir: str) -> str: """Render a markdown table summarizing the algorithms described by YAML data 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"] # TODO: unsure what to do with spec-url for now primary_impl = format_upstream_source(algdata["primary-upstream"]["source"]) - rows.append([ - f"[{alg_name}]({md_url})", - std_status, - primary_impl, - ]) + rows.append( + [ + f"[{alg_name}]({md_url})", + std_status, + primary_impl, + ] + ) tbl = tabulate.tabulate(rows, tablefmt="pipe", headers="firstrow") return tbl diff --git a/scripts/update_docs_from_yaml.py b/scripts/update_docs_from_yaml.py index 831278a6a..390c1df91 100755 --- a/scripts/update_docs_from_yaml.py +++ b/scripts/update_docs_from_yaml.py @@ -342,8 +342,6 @@ def do_it(liboqs_root): out_md.write(tabulate.tabulate(table, tablefmt="pipe", headers="firstrow", colalign=("center",))) 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)