Skip to content

Commit

Permalink
style: format all python scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Thing-han, Lim <[email protected]>
  • Loading branch information
potsrevennil committed Dec 4, 2024
1 parent 80f3f17 commit 372e74a
Show file tree
Hide file tree
Showing 6 changed files with 392 additions and 188 deletions.
8 changes: 5 additions & 3 deletions cbmc/proofs/lib/print_tool_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ def _format_versions(table):
if version:
v_str = f'<code><pre style="margin: 0">{version}</pre></code>'
else:
v_str = '<em>not found</em>'
v_str = "<em>not found</em>"
lines.append(
f'<tr><td style="font-weight: bold; padding-right: 1em; '
f'text-align: right;">{tool}:</td>'
f'<td>{v_str}</td></tr>')
f"<td>{v_str}</td></tr>"
)
lines.append("</table>")
return "\n".join(lines)

Expand All @@ -55,7 +56,8 @@ def _get_tool_versions():
continue
if proc.returncode:
logging.error(
"%s'%s --version' returned %s", err, tool, str(proc.returncode))
"%s'%s --version' returned %s", err, tool, str(proc.returncode)
)
continue
ret[tool] = out.strip()
return ret
Expand Down
18 changes: 10 additions & 8 deletions cbmc/proofs/lib/summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
def get_args():
"""Parse arguments for summarize script."""
parser = argparse.ArgumentParser(description=DESCRIPTION)
for arg in [{
for arg in [
{
"flags": ["--run-file"],
"help": "path to the Litani run.json file",
"required": True,
}]:
}
]:
flags = arg.pop("flags")
parser.add_argument(*flags, **arg)
return parser.parse_args()
Expand Down Expand Up @@ -111,7 +113,7 @@ def print_proof_results(out_file):
When printing, each string will render as a GitHub flavored Markdown table.
"""
output = "## Summary of CBMC proof results\n\n"
with open(out_file, encoding='utf-8') as run_json:
with open(out_file, encoding="utf-8") as run_json:
run_dict = json.load(run_json)
status_table, proof_table = _get_status_and_proof_summaries(run_dict)
for summary in (status_table, proof_table):
Expand All @@ -126,23 +128,23 @@ def print_proof_results(out_file):
print(output, file=handle)
handle.flush()
else:
logging.warning(
"$GITHUB_STEP_SUMMARY not set, not writing summary file")
logging.warning("$GITHUB_STEP_SUMMARY not set, not writing summary file")

msg = (
"Click the 'Summary' button to view a Markdown table "
"summarizing all proof results")
"summarizing all proof results"
)
if run_dict["status"] != "success":
logging.error("Not all proofs passed.")
logging.error(msg)
sys.exit(1)
logging.info(msg)


if __name__ == '__main__':
if __name__ == "__main__":
args = get_args()
logging.basicConfig(format="%(levelname)s: %(message)s")
try:
print_proof_results(args.run_file)
except Exception as ex: # pylint: disable=broad-except
except Exception as ex: # pylint: disable=broad-except
logging.critical("Could not print results. Exception: %s", str(ex))
Loading

0 comments on commit 372e74a

Please sign in to comment.