Code

Write the Daily Report

One run, two outputs:

  • a text report for people, easy to read in an email or chat;
  • a JSON summary for machines. Another program, a dashboard or tomorrow's run can read it back with json.loads.

Build both from one result dict, so they can never disagree.

result = {
    "date": "2026-11-26",
    "moved": 3,
    "skipped": [{"file": "notes.txt",
                 "reason": "target exists"}],
}

Join lines of text with "\n".join(lines). Turn a dict into JSON text with json.dumps(data, indent=2).

Assignment

  1. text_report(result) returns these lines joined with "\n":

    Morning run: 2026-11-26
    Moved: 3
    Skipped: 1
    - notes.txt: target exists
    Status: CHECK SKIPPED FILES

    Write one - file: reason line per skipped file, in order. The last line is Status: OK when nothing was skipped.

  2. summary(result) returns a dict: {"date": ..., "moved": <int>, "skipped": <how many were skipped>, "ok": <True if none>}.

  3. write_reports(result, folder) makes folder (and parents) if needed. Inside it, write text_report(result) to report.txt and json.dumps(summary(result), indent=2) to summary.json.