From ea0974f032311d43a6ab89830f1851987979118e Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Tue, 20 Oct 2026 10:50:50 +0200 Subject: [PATCH] Add all report formats shortcut --- docs/pptx-videos.md | 3 ++- tests/test_pptx_videos.py | 18 ++++++++++++++++++ tools/pptx_videos.py | 10 ++++++---- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/docs/pptx-videos.md b/docs/pptx-videos.md index 5d3b0e1..76a3149 100644 --- a/docs/pptx-videos.md +++ b/docs/pptx-videos.md @@ -10,11 +10,12 @@ Generate one or more report formats without keeping newly extracted videos: ```sh python3 tools/pptx_videos.py presentation.pptx --timings-only --report html,pdf -python3 tools/pptx_videos.py presentation.pptx --report html,typst,pdf,md,txt,json,ontime +python3 tools/pptx_videos.py presentation.pptx --report all ``` `--report` accepts comma-separated formats and can be repeated. Markdown and Ontime are included by default; an explicit `--report` replaces this selection. +Use `--report all` for every format, including PDF (requires Typst) and Ontime. Reports are saved as `timings.*` in `_videos`, or the directory supplied with `-o`. PDF uses the Typst CLI and retains `timings.typ` for editing. HTML and Typst/PDF include colored summary cards and pills; diff --git a/tests/test_pptx_videos.py b/tests/test_pptx_videos.py index 806b27b..5cbadbb 100644 --- a/tests/test_pptx_videos.py +++ b/tests/test_pptx_videos.py @@ -95,6 +95,24 @@ class VideoTests(unittest.TestCase): self.assertEqual([p.name for p in output.iterdir()], ['clip.mp4']) self.assertEqual((output / 'clip.mp4').read_bytes(), b'video fixture') + def test_all_reports_generate_every_format_once(self): + source = self.deck() + + def compile_pdf(command, **kwargs): + self.assertEqual(command[:2], ['typst', 'compile']) + Path(command[-1]).write_bytes(b'%PDF-test') + + with patch.object(videos.shutil, 'which', return_value='/tool'), \ + patch.object(videos, 'probe', return_value=(1.25, '32×24', 'mpeg4')), \ + patch.object(videos.subprocess, 'run', side_effect=compile_pdf) as compiler: + self.assertEqual(self.invoke(source, '--timings-only', '--report', ' ALL,md', '--report', 'pdf'), 0) + compiler.assert_called_once() + self.assertEqual( + {p.name for p in (self.root / 'sample_videos').iterdir()}, + {'timings.html', 'timings.typ', 'timings.pdf', 'timings.md', + 'timings.txt', 'timings.json', 'timings.ontime.json'}, + ) + def test_default_reports_include_ontime_and_explicit_choice_overrides(self): source = self.deck() with patch.object(videos.shutil, 'which', return_value='/ffprobe'), \ diff --git a/tools/pptx_videos.py b/tools/pptx_videos.py index ce5c2a6..018f955 100644 --- a/tools/pptx_videos.py +++ b/tools/pptx_videos.py @@ -165,9 +165,11 @@ def aligned_table(cells, markdown=True): def report_formats(value): formats = [item.strip().lower() for item in value.split(',')] - if any(item not in REPORT_FORMATS for item in formats): - raise argparse.ArgumentTypeError('Choose comma-separated formats from: ' + ', '.join(REPORT_FORMATS)) - return formats + if any(item not in (*REPORT_FORMATS, 'all') for item in formats): + raise argparse.ArgumentTypeError('Choose comma-separated formats from: ' + ', '.join((*REPORT_FORMATS, 'all'))) + return list(dict.fromkeys( + format for item in formats for format in (REPORT_FORMATS if item == 'all' else (item,)) + )) def report_data(source, rows, uses, external, out): @@ -363,7 +365,7 @@ def main(): mode.add_argument('--timings-only', action='store_true', help='Report video timings without keeping newly extracted videos') parser.add_argument('--overwrite', action='store_true', help='Overwrite already extracted files') parser.add_argument('--report', type=report_formats, action='append', metavar='FORMAT[,FORMAT...]', - help='Report formats: html, typst, pdf, md, txt, json, ontime. Repeatable; default: md,ontime. PDF requires typst and keeps timings.typ.') + help='Report formats: html, typst, pdf, md, txt, json, ontime, or all. Repeatable; default: md,ontime. PDF requires typst and keeps timings.typ.') args = parser.parse_args() if args.extract_only and args.report: parser.error('--report cannot be combined with --extract-only.')