Add all report formats shortcut
Beffroi/beffroi-tools/pipeline/head This commit looks good Details

This commit is contained in:
Dandaedre 2026-10-20 10:50:50 +02:00
parent e74f72dac8
commit ea0974f032
3 changed files with 26 additions and 5 deletions

View File

@ -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 `<presentation-stem>_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;

View File

@ -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'), \

View File

@ -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.')