
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
-
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 FILESWrite one
- file: reasonline per skipped file, in order. The last line isStatus: OKwhen nothing was skipped. -
summary(result)returns a dict:{"date": ..., "moved": <int>, "skipped": <how many were skipped>, "ok": <True if none>}. -
write_reports(result, folder)makesfolder(and parents) if needed. Inside it, writetext_report(result)toreport.txtandjson.dumps(summary(result), indent=2)tosummary.json.
-
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 FILESWrite one
- file: reasonline per skipped file, in order. The last line isStatus: OKwhen nothing was skipped. -
summary(result)returns a dict:{"date": ..., "moved": <int>, "skipped": <how many were skipped>, "ok": <True if none>}. -
write_reports(result, folder)makesfolder(and parents) if needed. Inside it, writetext_report(result)toreport.txtandjson.dumps(summary(result), indent=2)tosummary.json.
Press Run to try your code, then Check to test it.