GitHub

UserDirectoriesService

API reference for UserDirectoriesService.

The user's home and each kind of directory for an application name: make builds one by a platform's rules, and UserDirectoriesService(home=..., config=..., ...) from an effect and four functions (a test double, say). Every operation fails with a PlatformError: NotFound when the home it needs is not set, Unknown when the ConfigProvider cannot be read.

Attributes

AttributeTypeDescription
homeEffect[str, PlatformError]

The current user's home directory (HOME, or USERPROFILE on Windows).

Functions

__init__

__init__(*, home, config, data, cache, state) -> None
ParameterTypeDescription
homeEffect[str, PlatformError]
configCallable[[str], Effect[str, PlatformError]]
dataCallable[[str], Effect[str, PlatformError]]
cacheCallable[[str], Effect[str, PlatformError]]
stateCallable[[str], Effect[str, PlatformError]]
def __init__(
    self,
    *,
    home: Effect[str, PlatformError],
    config: Callable[[str], Effect[str, PlatformError]],
    data: Callable[[str], Effect[str, PlatformError]],
    cache: Callable[[str], Effect[str, PlatformError]],
    state: Callable[[str], Effect[str, PlatformError]],
) -> None:
    require_effect(home, "home")
    self._home = home
    self._config = config
    self._data = data
    self._cache = cache
    self._state = state

config

config(app_name) -> Effect[str, PlatformError]

Where app_name keeps its settings.

ParameterTypeDescription
app_namestr

Returns Effect[str, PlatformError]

def config(self, app_name: str) -> Effect[str, PlatformError]:
    """Where ``app_name`` keeps its settings."""
    return self._config(app_name)

data

data(app_name) -> Effect[str, PlatformError]

Where app_name keeps data it cannot regenerate.

ParameterTypeDescription
app_namestr

Returns Effect[str, PlatformError]

def data(self, app_name: str) -> Effect[str, PlatformError]:
    """Where ``app_name`` keeps data it cannot regenerate."""
    return self._data(app_name)

cache

cache(app_name) -> Effect[str, PlatformError]

Where app_name keeps data it can regenerate.

ParameterTypeDescription
app_namestr

Returns Effect[str, PlatformError]

def cache(self, app_name: str) -> Effect[str, PlatformError]:
    """Where ``app_name`` keeps data it can regenerate."""
    return self._cache(app_name)

state

state(app_name) -> Effect[str, PlatformError]

Where app_name keeps logs, history and other state that is not user data.

ParameterTypeDescription
app_namestr

Returns Effect[str, PlatformError]

def state(self, app_name: str) -> Effect[str, PlatformError]:
    """Where ``app_name`` keeps logs, history and other state that is
    not user data."""
    return self._state(app_name)