To avoid quoting and escaping issues, avoid `Rscript [options] -e {expr}` but use `Rscript [options] path/to/file_with_expr.R`
(code: str)
| 109 | |
| 110 | @contextlib.contextmanager |
| 111 | def _r_code_in_tempfile(code: str) -> Generator[str]: |
| 112 | """ |
| 113 | To avoid quoting and escaping issues, avoid `Rscript [options] -e {expr}` |
| 114 | but use `Rscript [options] path/to/file_with_expr.R` |
| 115 | """ |
| 116 | with tempfile.TemporaryDirectory() as tmpdir: |
| 117 | fname = os.path.join(tmpdir, 'script.R') |
| 118 | with open(fname, 'w') as f: |
| 119 | f.write(_inline_r_setup(textwrap.dedent(code))) |
| 120 | yield fname |
| 121 | |
| 122 | |
| 123 | def get_env_patch(venv: str) -> PatchesT: |
no test coverage detected