Answer principles round 1: 1 🔴, 7 🟡 (0 misread); every effect is handed in as an argument, no test patches a global, and the traces principle scopes tools that run on their user's machine
CI / tests (pull_request) Successful in 3m43s
CI / tests (pull_request) Successful in 3m43s
This commit is contained in:
@@ -14,31 +14,28 @@ its plain name. README.md → Install has the crontab line that runs it daily.
|
||||
It prints how many files it compressed. It exits 1, saying why, on any argument but --help or -h,
|
||||
and at the first file it cannot compress, leaving that file and every one after it plain.
|
||||
"""
|
||||
import os
|
||||
import pathlib
|
||||
import stat
|
||||
import sys
|
||||
import time
|
||||
import typing
|
||||
|
||||
from transcript_archive.location import archive_root
|
||||
from text_files.compressed import compress, SUFFIX
|
||||
from failure import Failure
|
||||
from review_rules.review_folder import REPORTS
|
||||
from text_files.compressed import SUFFIX
|
||||
|
||||
# Why 30 days: docs/decisions.md → `archives: gzip each transcript in loop-claude's archive and each file in the review folders 30 days after it last changed, keeping all of them`.
|
||||
AGE_DAYS = 30
|
||||
|
||||
|
||||
def main(argv: list[str], env: typing.Mapping[str, str] = os.environ, home: pathlib.Path | None = None, now: float | None = None) -> int:
|
||||
def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, now: typing.Callable[[], float], compress: typing.Callable[[pathlib.Path], Failure | None]) -> int:
|
||||
if argv in (["-h"], ["--help"]):
|
||||
print(__doc__.strip())
|
||||
return 0
|
||||
if argv:
|
||||
print(f"unknown arguments {' '.join(argv)}; usage: compress-archives", file=sys.stderr)
|
||||
return 1
|
||||
home = home or pathlib.Path.home()
|
||||
cutoff = (time.time() if now is None else now) - AGE_DAYS * 24 * 60 * 60
|
||||
cutoff = now() - AGE_DAYS * 24 * 60 * 60
|
||||
count = 0
|
||||
for path in [*old_files(archive_root(home, env), "*.jsonl", cutoff), *old_files(home / REPORTS, "*", cutoff)]:
|
||||
if failed := compress(path):
|
||||
|
||||
Reference in New Issue
Block a user