#!/usr/bin/env python3 """Organize local reports and logs. Dry run by default; never delete files.""" import argparse import json from pathlib import Path import sys ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT)) from tools.runtime.report_files import migration_plan, retention_plan, apply_moves def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--apply', action='store_true') parser.add_argument('--keep-verifications', type=int, default=5) args = parser.parse_args() moves = migration_plan() + retention_plan(keep=args.keep_verifications) if args.apply and moves: record = apply_moves(moves) print(json.dumps({'moved': len(moves), 'deleted': 0, 'journal': str(record)})) else: print(json.dumps({'dry_run': True, 'moves': moves, 'deleted': 0}, ensure_ascii=False, indent=2)) if __name__ == '__main__': main()