gui.editor.open_in_editor(template, path, line=None, launch=subprocess.Popen)
Start the editor on a file and return at once.
Parameters
| template |
str |
An editor template, or an empty string for default_template. |
required |
| path |
Path | str |
The file to open. |
required |
| line |
int | None |
The 1-based line, or None. |
None |
| launch |
Callable[…, object] |
Starts the argument list; replaceable for tests. It is called without a shell. |
subprocess.Popen |
Returns
|
list[str] |
list[str]: The argument list that was started. |
Raises
|
ValueError |
If the template is unusable. |
|
OSError |
If the editor program cannot be started. |
Examples
from spotregen.gui.editor import open_in_editor
started = []
open_in_editor("code --goto {file}:{line}", "regen/units/a.toml", 12, started.append)
print(started)
[['code', '--goto', 'regen/units/a.toml:12']]