ddp_utils.browser.backends.native.discovery¶
import ddp_utils.browser.backends.native.discovery
Cross-platform discovery for native browser executables.
- class ddp_utils.browser.backends.native.discovery.NativeBrowserDiscovery(*, platform: str | None = None, environment: ~typing.Mapping[str, str] | None = None, path_lookup: ~typing.Callable[[str], str | None] = <function which>, standard_paths: ~typing.Mapping[~ddp_utils.browser.contracts.BrowserProduct, ~typing.Sequence[~pathlib.Path]] | None = None)¶
Bases:
objectResolve supported browser products to executable paths.
Parameters
Name
Type
Description
platform
str | None
Platform identifier. Defaults to
sys.platform.environment
Mapping[str, str] | None
Environment mapping used for standard paths.
path_lookup
Callable[[str], str | None]
Function compatible with
shutil.which.standard_paths
Mapping[BrowserProduct, Sequence[Path]] | None
Optional complete replacement for standard path candidates.
Examples
Resolve the host Firefox installation:
discovery = NativeBrowserDiscovery() installation = discovery.resolve("firefox")
Initialize deterministic discovery dependencies.
Parameters
Name
Type
Description
platform
str | None
Platform identifier. Defaults to
sys.platform.environment
Mapping[str, str] | None
Environment mapping used for standard paths.
path_lookup
Callable[[str], str | None]
Executable lookup function.
standard_paths
Mapping[BrowserProduct, Sequence[Path]] | None
Optional standard-path override for tests or policy.
Examples
Inject a deterministic PATH lookup for a unit test:
discovery = NativeBrowserDiscovery(path_lookup=lambda name: None)
- resolve(product: BrowserProduct | str, *, executable: str | Path | None = None) NativeBrowserInstallation¶
Resolve one executable or raise a precise startup error.
Parameters
Name
Type
Description
product
BrowserProduct | str
Supported browser product.
executable
str | Path | None
Optional explicit executable path.
Returns
Type
Description
Resolved browser installation with discovery source.
Raises
Exception
Description
No executable exists for the requested product.
Examples
Prefer a project-supplied Brave executable:
installation = discovery.resolve( "brave", executable="/opt/brave/brave" )