
Invoke the bundled quartifyr-styling Python CLI via pyro
Source:R/run-python.R
dot-run_quartifyr_styling_cli.RdInternal helper every exported styling_*() function funnels through –
the single bridge point, so docx-generation/layout logic is never
reimplemented in R (mirrors ../deckifyr's .run_deckifyr_cli() pattern).
Always requests --json so results come back as a parsed R list rather
than needing prose scraping.
Details
Why this isn't a thin wrapper around pyro::run_python_script():
confirmed against a real pyro install, run_python_script() calls
processx::run(..., error_on_status = TRUE) and, on any non-zero exit,
discards the captured stdout/stderr entirely and raises a bare
"<script_name> failed." – so quartifyr-styling's own diagnostic JSON
(emitted to stderr on error when --json is passed, see
inst/python/quartifyr_styling/cli.py's module docstring) would
otherwise be lost. The fix is stderr_callback: processx invokes it per
output chunk while the process is still running, before the exit-status
check fires, so output captured that way survives even when the call
ultimately errors. This only works because cli.py deliberately writes
its JSON error payload to stderr rather than stdout on the error path –
don't change one side of this handshake without the other.