style: Apply linter formatting

This commit is contained in:
Paul Gauthier (aider) 2024-12-13 12:34:34 -08:00
parent 834e2f9304
commit a691d1750a

View file

@ -31,7 +31,7 @@ def format_text_table(model_stats):
"""Format model statistics as a text table.""" """Format model statistics as a text table."""
total_tokens = sum(model_stats.values()) total_tokens = sum(model_stats.values())
lines = [] lines = []
lines.append("\nModel Token Usage Summary:") lines.append("\nModel Token Usage Summary:")
lines.append("-" * 80) lines.append("-" * 80)
lines.append(f"{'Model Name':<40} {'Total Tokens':>15} {'Percent':>10}") lines.append(f"{'Model Name':<40} {'Total Tokens':>15} {'Percent':>10}")
@ -43,14 +43,14 @@ def format_text_table(model_stats):
lines.append("-" * 80) lines.append("-" * 80)
lines.append(f"{'TOTAL':<40} {total_tokens:>15,} {100:>9.1f}%") lines.append(f"{'TOTAL':<40} {total_tokens:>15,} {100:>9.1f}%")
return "\n".join(lines) return "\n".join(lines)
def format_html_table(model_stats): def format_html_table(model_stats):
"""Format model statistics as an HTML table.""" """Format model statistics as an HTML table."""
total_tokens = sum(model_stats.values()) total_tokens = sum(model_stats.values())
html = [ html = [
"<html>", "<html>",
"<head>", "<head>",
@ -65,9 +65,12 @@ def format_html_table(model_stats):
"<body>", "<body>",
"<h2>Model Token Usage Summary</h2>", "<h2>Model Token Usage Summary</h2>",
"<table>", "<table>",
"<tr><th>Model Name</th><th class='right'>Total Tokens</th><th class='right'>Percent</th></tr>" (
"<tr><th>Model Name</th><th class='right'>Total Tokens</th><th"
" class='right'>Percent</th></tr>"
),
] ]
for model, tokens in sorted(model_stats.items(), key=lambda x: x[1], reverse=True): for model, tokens in sorted(model_stats.items(), key=lambda x: x[1], reverse=True):
percentage = (tokens / total_tokens) * 100 if total_tokens > 0 else 0 percentage = (tokens / total_tokens) * 100 if total_tokens > 0 else 0
html.append( html.append(
@ -75,13 +78,13 @@ def format_html_table(model_stats):
f"<td class='right'>{tokens:,}</td>" f"<td class='right'>{tokens:,}</td>"
f"<td class='right'>{percentage:.1f}%</td></tr>" f"<td class='right'>{percentage:.1f}%</td></tr>"
) )
html.append( html.append(
f"<tr><td><strong>TOTAL</strong></td>" "<tr><td><strong>TOTAL</strong></td>"
f"<td class='right'><strong>{total_tokens:,}</strong></td>" f"<td class='right'><strong>{total_tokens:,}</strong></td>"
f"<td class='right'><strong>100.0%</strong></td></tr>" "<td class='right'><strong>100.0%</strong></td></tr>"
) )
html.extend(["</table>", "</body>", "</html>"]) html.extend(["</table>", "</body>", "</html>"])
return "\n".join(html) return "\n".join(html)