Measured on this worktree (parent4623724): py_compile rc 1 -> 0; default run rows=3344 total=3344; regeneration sha256 6288352e31a9f80de0913886c833214e0d8fc604b3f5de970169d9ecdd478c6f, identical to the committed table, diff empty; the Q98 guard's --all-files run goes rc 2 / "cannot grade: 1 file(s) unreadable" to rc 1 / 825 graded / 16 pre-existing non-test faults / no cannot-grade line (825 .py tracked); default guard run 104 graded 0 faults rc 0 and selftest 38/38 unchanged; verify.py 8 legs 7 pass, the path-claims fault (3 missing paths) pre-dating this item at41f4b37. Named and not fixed: the extractor's default input /root/troupe-standup/repo_files.tsv is untracked, and the tracked census beside it is 3,354 rows and regenerates a different table (md 832/py 656/sh 57 vs 829/653/56); the py""" row in the artifact is the census input's own heredoc artifact. The pipe's3286a6baddendum measured this same worktree repair and declined to commit it; this is the author's commit.
63 lines
2.1 KiB
Python
Executable File
63 lines
2.1 KiB
Python
Executable File
|
|
#!/usr/bin/env python3
|
|
"""ext-census: extension census of the Troupe standup repo.
|
|
|
|
Reads the curated file census `repo_files.tsv` (3,344 data rows) in the
|
|
troupe repo, applies a stated rule, and emits an ordered table of
|
|
extension -> file_count.
|
|
|
|
Rule
|
|
----
|
|
basename = final path component.
|
|
. dotfile (leading dot, e.g. .gitignore) -> "(none)"
|
|
. no dot in basename -> "(none)"
|
|
. otherwise -> substring after LAST dot, lowercased
|
|
|
|
Paths default to the curated census at the repo root and to the ledger
|
|
artifact, and are overridable with EXT_CENSUS_SRC / EXT_CENSUS_OUT so a
|
|
reader can regenerate into scratch instead of clobbering the committed
|
|
table. (Q101: four string literals had a real line break where "\n"
|
|
belonged, so this file did not compile; repaired 2026-10-27.)
|
|
"""
|
|
import collections
|
|
import os
|
|
import sys
|
|
|
|
SRC = os.environ.get("EXT_CENSUS_SRC", "/root/troupe-standup/repo_files.tsv")
|
|
OUT = os.environ.get(
|
|
"EXT_CENSUS_OUT", "/root/.hermes/wizard-outputs/ledger/ext-census.tsv"
|
|
)
|
|
|
|
def ext_of(basename):
|
|
if basename.startswith(".") or "." not in basename:
|
|
return "(none)"
|
|
return basename.rsplit(".", 1)[1].lower()
|
|
|
|
def parse_census(path):
|
|
rows = []
|
|
with open(path) as fh:
|
|
for line in fh:
|
|
line = line.rstrip("\n")
|
|
if not line.strip():
|
|
continue
|
|
if line.startswith("rank\tpath"):
|
|
continue
|
|
key, _, val = line.partition("\t")
|
|
rows.append((key.strip(), val.strip()))
|
|
return rows
|
|
|
|
def main():
|
|
rows = parse_census(SRC)
|
|
cnt = collections.Counter(ext_of(os.path.basename(p)) for _, p in rows)
|
|
total = sum(cnt.values())
|
|
if total != len(rows):
|
|
sys.stderr.write("WARNING: parsed rows=%d counts=%d\n" % (len(rows), total))
|
|
with open(OUT, "w") as fh:
|
|
fh.write("rank\textension\tfile_count\n")
|
|
for i, (ext, n) in enumerate(cnt.most_common(), 1):
|
|
fh.write("%d\t%s\t%d\n" % (i, ext, n))
|
|
print("rows=%d total=%d -> %s" % (len(rows), total, OUT))
|
|
|
|
if __name__ == "__main__":
|
|
main()
|