A source of configuration Node values, looked up by path.
load gives None for an absent path and fails with
SourceError only when the source cannot be read; absence is what
or_else falls back on. Build one with make, from_env,
from_unknown, from_dot_env_contents or from_dir.
Functions#
load#
load(path) -> Effect[Node | None, SourceError]The node at path after this provider's path transformations,
or None when there is none.
| Parameter | Type | Description |
|---|---|---|
path | PathInput |
Returns Effect[Node | None, SourceError]
@abstractmethod
def load(self, path: PathInput) -> Effect[Node | None, SourceError]:
"""The node at ``path`` after this provider's path transformations,
or ``None`` when there is none."""map_input#
map_input(f) -> ConfigProviderA provider that applies f to lookup paths after its existing
transformations. or_else providers apply it to both operands.
| Parameter | Type | Description |
|---|---|---|
f | Callable[[Path], PathInput] |
Returns ConfigProvider
@abstractmethod
def map_input(self, f: Callable[[Path], PathInput]) -> ConfigProvider:
"""A provider that applies ``f`` to lookup paths after its existing
transformations. ``or_else`` providers apply it to both operands."""or_else#
or_else(that) -> ConfigProviderLook up in this provider, then in that when the path is
absent here. A SourceError does not fall back, and found
containers are not merged.
| Parameter | Type | Description |
|---|---|---|
that | ConfigProvider |
Returns ConfigProvider
def or_else(self, that: ConfigProvider) -> ConfigProvider:
"""Look up in this provider, then in ``that`` when the path is
absent here. A ``SourceError`` does not fall back, and found
containers are not merged."""
return _OrElse(self, that)nested#
nested(prefix) -> ConfigProviderLook every path up under prefix.
| Parameter | Type | Description |
|---|---|---|
prefix | str | PathInput |
Returns ConfigProvider
def nested(self, prefix: str | PathInput) -> ConfigProvider:
"""Look every path up under ``prefix``."""
head = (prefix,) if isinstance(prefix, str) else to_path(prefix)
return self.map_input(lambda path: head + path)constant_case#
constant_case() -> ConfigProviderConvert string segments to CONSTANT_CASE (Effect's configCase:
"databaseHost" is "DATABASE_HOST", "api-v2" is
"API_V2"); numeric segments are kept.
Returns ConfigProvider
def constant_case(self) -> ConfigProvider:
"""Convert string segments to CONSTANT_CASE (Effect's ``configCase``:
``"databaseHost"`` is ``"DATABASE_HOST"``, ``"api-v2"`` is
``"API_V2"``); numeric segments are kept."""
return self.map_input(_constant_case)