Skip to content

hertzforge.service.dialogs

dialogs

The operating system's open and save dialogs, shown by the service itself.

A browser never hands a page the path of a file it picks, only its contents, and the service reads a file where it is. hertzforge with no command serves the interface to a browser on the same machine, so the service can show the system's own dialog there and answer with the paths chosen (files.choose): AppleScript's on macOS, Windows Forms through PowerShell on Windows, and zenity or kdialog on Linux. Where none can be shown (no desktop session, over SSH, no dialog program), DialogUnavailable says so and the shell asks for a typed path instead.

Classes:

Name Description
DialogUnavailable

No dialog can be shown where the service runs; the message says why.

Functions:

Name Description
command

The program and arguments that show the dialog for purpose ('open' one

paths_from

The paths a dialog printed, one a line; blank lines left out.

choose

Show the dialog for purpose and wait for it: the paths chosen, or none when

Classes

DialogUnavailable

Bases: Exception

No dialog can be shown where the service runs; the message says why.

Functions:

command

command(purpose: str, name: str = '', platform: str = platform, which: Callable[[str], str | None] = which, environ: dict[str, str] | None = None) -> list[str]

The program and arguments that show the dialog for purpose ('open' one project, 'import' several files, 'save' a project as name) and print each path chosen on a line of its own. DialogUnavailable where none can be shown.

paths_from

paths_from(output: str) -> list[str]

The paths a dialog printed, one a line; blank lines left out.

choose

choose(purpose: str, name: str = '', run: Callable[..., CompletedProcess] = run, **where: object) -> list[str]

Show the dialog for purpose and wait for it: the paths chosen, or none when it was cancelled. where reaches command (the platform, which, the environment). DialogUnavailable when no dialog can be shown, or it fails.