Skip to content

Commit

Permalink
Merge pull request #1240 from twm/print-static-total
Browse files Browse the repository at this point in the history
Print static file weight
  • Loading branch information
twm authored Dec 4, 2024
2 parents 3f5219e + b82319d commit 784075a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions bin/compile-static.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import re
import shlex
from asyncio.subprocess import PIPE
from collections import deque
from dataclasses import dataclass, field
from pathlib import Path
from shutil import rmtree
Expand All @@ -58,7 +57,6 @@
import brotli
import tinycss2
import zopfli.gzip
from tinycss2.ast import AtRule, ParseError

repo_root = Path(__file__).parent.parent

Expand Down Expand Up @@ -128,6 +126,7 @@ def summarize(self) -> str:
"ORIGINAL ZOPFLI (.gz) BROTLI (.br) FILE",
"--------- --------------- -------------- ------------------------------------------",
]
base_sum = gz_sum = br_sum = 0

def pct(size, total) -> str:
if size is None:
Expand All @@ -141,6 +140,9 @@ def pct(size, total) -> str:
return f"{left:>9} {right:>5}"

for r in self._written:
base_sum += r.base_size
gz_sum += r.base_size if r.gz_size is None else r.gz_size
br_sum += r.base_size if r.gz_size is None else r.br_size
lines.append(
" ".join(
[
Expand All @@ -152,6 +154,17 @@ def pct(size, total) -> str:
)
)

lines.append(lines[1])
lines.append(
" ".join(
[
f"{base_sum:>9,d} ",
pct(gz_sum, base_sum),
pct(br_sum, base_sum),
" TOTAL",
]
)
)
return "\n".join(lines)


Expand Down

0 comments on commit 784075a

Please sign in to comment.