ddp_utils.browser.registry¶
import ddp_utils.browser.registry
Explicit registry for concrete browser backend providers.
- class ddp_utils.browser.registry.BackendRegistry¶
Bases:
objectResolve neutral configuration to one explicitly registered backend.
Examples
Build the standard registry and resolve native process mode:
registry = BackendRegistry.with_defaults() backend = registry.resolve(config)
Initialize an empty registry with no implicit technology imports.
Examples
Register only the backends permitted by an application:
registry = BackendRegistry()
- classmethod with_defaults() BackendRegistry¶
Create the dependency-light registry available in the core package.
Returns
Type
Description
Registry containing the native process backend builder. Optional automation providers register themselves without core imports.
Examples
Create a factory with core defaults:
factory = BrowserFactory(registry=BackendRegistry.with_defaults())
- register(provider: str, builder: Callable[[BrowserConfig], BrowserBackend], *, replace: bool = False) None¶
Register one concrete provider builder.
Parameters
Name
Type
Description
provider
str
Stable provider name returned by
BrowserConfig.provider.builder
Callable[[BrowserConfig], BrowserBackend]
Callable producing a backend for validated configuration.
replace
bool
Permit intentional replacement of an existing provider.
Raises
Exception
Description
The name is empty, the builder is not callable, or a provider already exists without
replace.Examples
Register the Playwright provider only when its extra is installed:
registry.register("playwright", build_playwright_backend)
- unregister(provider: str) bool¶
Remove one provider registration.
Parameters
Name
Type
Description
provider
str
Stable provider name.
Returns
Type
Description
bool
Truewhen an existing provider was removed.Examples
Disable a provider for one controlled runtime:
removed = registry.unregister("playwright")
- providers() tuple[str, ...]¶
Return registered provider names in deterministic order.
Returns
Type
Description
tuple[str, …]
Sorted tuple of provider names.
Examples
Display available providers before project startup:
print(registry.providers())
- resolve(config: BrowserConfig) BrowserBackend¶
Build the exact backend selected by validated configuration.
Parameters
Name
Type
Description
config
Validated neutral browser configuration.
Returns
Type
Description
Concrete backend whose descriptor matches the requested provider and browser product.
Raises
Exception
Description
The provider is unavailable or returns a contradictory descriptor.
Examples
Resolve without importing Selenium or Playwright from core code:
backend = registry.resolve(config)