Source code for platformdirs

"""Utilities for determining application-specific dirs.

Provides convenience functions (e.g. :func:`user_data_dir`, :func:`user_config_path`), a :data:`PlatformDirs` class that
auto-detects the current platform, and the :class:`~platformdirs.api.PlatformDirsABC` base class.

See <https://github.com/platformdirs/platformdirs> for details and usage.

"""

from __future__ import annotations

import os
import sys
from typing import TYPE_CHECKING

from .api import PlatformDirsABC
from .version import __version__
from .version import __version_tuple__ as __version_info__

if TYPE_CHECKING:
    from pathlib import Path
    from typing import Literal

if sys.platform == "win32":
    from platformdirs.windows import Windows as _Result
elif sys.platform == "darwin":
    from platformdirs.macos import MacOS as _Result
else:
    from platformdirs.unix import Unix as _Result


def _set_platform_dir_class() -> type[PlatformDirsABC]:
    if os.getenv("ANDROID_DATA") == "/data" and os.getenv("ANDROID_ROOT") == "/system":
        if os.getenv("SHELL") or os.getenv("PREFIX"):
            return _Result

        from platformdirs.android import _android_folder  # noqa: PLC0415

        if _android_folder() is not None:
            from platformdirs.android import Android  # noqa: PLC0415

            return Android  # return to avoid redefinition of a result

    return _Result


if TYPE_CHECKING:
    # Work around mypy issue: https://github.com/python/mypy/issues/10962
    PlatformDirs = _Result
else:
    PlatformDirs = _set_platform_dir_class()  #: Currently active platform
AppDirs = PlatformDirs  #: Backwards compatibility with appdirs


[docs] def user_data_dir( # noqa: PLR0913, PLR0917 appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, roaming: bool = False, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 use_site_for_root: bool = False, # noqa: FBT001, FBT002 ) -> str: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. :returns: data directory tied to the user """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, roaming=roaming, ensure_exists=ensure_exists, use_site_for_root=use_site_for_root, ).user_data_dir
[docs] def site_data_dir( appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, multipath: bool = False, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> str: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: data directory shared by users """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, multipath=multipath, ensure_exists=ensure_exists, ).site_data_dir
[docs] def user_config_dir( # noqa: PLR0913, PLR0917 appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, roaming: bool = False, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 use_site_for_root: bool = False, # noqa: FBT001, FBT002 ) -> str: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. :returns: config directory tied to the user """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, roaming=roaming, ensure_exists=ensure_exists, use_site_for_root=use_site_for_root, ).user_config_dir
[docs] def site_config_dir( appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, multipath: bool = False, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> str: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: config directory shared by users """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, multipath=multipath, ensure_exists=ensure_exists, ).site_config_dir
[docs] def user_cache_dir( # noqa: PLR0913, PLR0917 appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 use_site_for_root: bool = False, # noqa: FBT001, FBT002 ) -> str: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. :returns: cache directory tied to the user """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, opinion=opinion, ensure_exists=ensure_exists, use_site_for_root=use_site_for_root, ).user_cache_dir
[docs] def site_cache_dir( appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> str: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: cache directory shared by users """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, opinion=opinion, ensure_exists=ensure_exists, ).site_cache_dir
[docs] def user_state_dir( # noqa: PLR0913, PLR0917 appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, roaming: bool = False, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 use_site_for_root: bool = False, # noqa: FBT001, FBT002 ) -> str: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. :returns: state directory tied to the user """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, roaming=roaming, ensure_exists=ensure_exists, use_site_for_root=use_site_for_root, ).user_state_dir
[docs] def site_state_dir( appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> str: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: state directory shared by users """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, ensure_exists=ensure_exists, ).site_state_dir
[docs] def user_log_dir( # noqa: PLR0913, PLR0917 appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 use_site_for_root: bool = False, # noqa: FBT001, FBT002 ) -> str: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. :returns: log directory tied to the user """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, opinion=opinion, ensure_exists=ensure_exists, use_site_for_root=use_site_for_root, ).user_log_dir
[docs] def site_log_dir( appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> str: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: log directory shared by users """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, opinion=opinion, ensure_exists=ensure_exists, ).site_log_dir
[docs] def user_documents_dir() -> str: """:returns: documents directory tied to the user""" return PlatformDirs().user_documents_dir
[docs] def user_downloads_dir() -> str: """:returns: downloads directory tied to the user""" return PlatformDirs().user_downloads_dir
[docs] def user_pictures_dir() -> str: """:returns: pictures directory tied to the user""" return PlatformDirs().user_pictures_dir
[docs] def user_videos_dir() -> str: """:returns: videos directory tied to the user""" return PlatformDirs().user_videos_dir
[docs] def user_music_dir() -> str: """:returns: music directory tied to the user""" return PlatformDirs().user_music_dir
[docs] def user_desktop_dir() -> str: """:returns: desktop directory tied to the user""" return PlatformDirs().user_desktop_dir
[docs] def user_projects_dir() -> str: """:returns: projects directory tied to the user""" return PlatformDirs().user_projects_dir
[docs] def user_publicshare_dir() -> str: """:returns: public share directory tied to the user""" return PlatformDirs().user_publicshare_dir
[docs] def user_templates_dir() -> str: """:returns: templates directory tied to the user""" return PlatformDirs().user_templates_dir
[docs] def user_fonts_dir() -> str: """:returns: fonts directory tied to the user""" return PlatformDirs().user_fonts_dir
[docs] def user_preference_dir() -> str: """:returns: preference directory tied to the user""" return PlatformDirs().user_preference_dir
[docs] def user_bin_dir() -> str: """:returns: bin directory tied to the user""" return PlatformDirs().user_bin_dir
[docs] def site_bin_dir() -> str: """:returns: bin directory shared by users""" return PlatformDirs().site_bin_dir
[docs] def user_applications_dir() -> str: """:returns: applications directory tied to the user""" return PlatformDirs().user_applications_dir
[docs] def site_applications_dir( multipath: bool = False, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> str: """:param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: applications directory shared by users """ return PlatformDirs( multipath=multipath, ensure_exists=ensure_exists, ).site_applications_dir
[docs] def user_runtime_dir( # noqa: PLR0913, PLR0917 appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 use_site_for_root: bool = False, # noqa: FBT001, FBT002 ) -> str: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. :returns: runtime directory tied to the user """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, opinion=opinion, ensure_exists=ensure_exists, use_site_for_root=use_site_for_root, ).user_runtime_dir
[docs] def site_runtime_dir( appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> str: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: runtime directory shared by users """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, opinion=opinion, ensure_exists=ensure_exists, ).site_runtime_dir
[docs] def user_data_path( # noqa: PLR0913, PLR0917 appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, roaming: bool = False, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 use_site_for_root: bool = False, # noqa: FBT001, FBT002 ) -> Path: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. :returns: data path tied to the user """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, roaming=roaming, ensure_exists=ensure_exists, use_site_for_root=use_site_for_root, ).user_data_path
[docs] def site_data_path( appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, multipath: bool = False, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> Path: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: data path shared by users """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, multipath=multipath, ensure_exists=ensure_exists, ).site_data_path
[docs] def user_config_path( # noqa: PLR0913, PLR0917 appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, roaming: bool = False, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 use_site_for_root: bool = False, # noqa: FBT001, FBT002 ) -> Path: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. :returns: config path tied to the user """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, roaming=roaming, ensure_exists=ensure_exists, use_site_for_root=use_site_for_root, ).user_config_path
[docs] def site_config_path( appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, multipath: bool = False, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> Path: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: config path shared by users """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, multipath=multipath, ensure_exists=ensure_exists, ).site_config_path
[docs] def site_cache_path( appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> Path: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: cache path shared by users """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, opinion=opinion, ensure_exists=ensure_exists, ).site_cache_path
[docs] def user_cache_path( # noqa: PLR0913, PLR0917 appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 use_site_for_root: bool = False, # noqa: FBT001, FBT002 ) -> Path: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. :returns: cache path tied to the user """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, opinion=opinion, ensure_exists=ensure_exists, use_site_for_root=use_site_for_root, ).user_cache_path
[docs] def user_state_path( # noqa: PLR0913, PLR0917 appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, roaming: bool = False, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 use_site_for_root: bool = False, # noqa: FBT001, FBT002 ) -> Path: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. :returns: state path tied to the user """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, roaming=roaming, ensure_exists=ensure_exists, use_site_for_root=use_site_for_root, ).user_state_path
[docs] def site_state_path( appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> Path: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: state path shared by users """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, ensure_exists=ensure_exists, ).site_state_path
[docs] def user_log_path( # noqa: PLR0913, PLR0917 appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 use_site_for_root: bool = False, # noqa: FBT001, FBT002 ) -> Path: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. :returns: log path tied to the user """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, opinion=opinion, ensure_exists=ensure_exists, use_site_for_root=use_site_for_root, ).user_log_path
[docs] def site_log_path( appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> Path: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: log path shared by users """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, opinion=opinion, ensure_exists=ensure_exists, ).site_log_path
[docs] def user_documents_path() -> Path: """:returns: documents path tied to the user""" return PlatformDirs().user_documents_path
[docs] def user_downloads_path() -> Path: """:returns: downloads path tied to the user""" return PlatformDirs().user_downloads_path
[docs] def user_pictures_path() -> Path: """:returns: pictures path tied to the user""" return PlatformDirs().user_pictures_path
[docs] def user_videos_path() -> Path: """:returns: videos path tied to the user""" return PlatformDirs().user_videos_path
[docs] def user_music_path() -> Path: """:returns: music path tied to the user""" return PlatformDirs().user_music_path
[docs] def user_desktop_path() -> Path: """:returns: desktop path tied to the user""" return PlatformDirs().user_desktop_path
[docs] def user_projects_path() -> Path: """:returns: projects path tied to the user""" return PlatformDirs().user_projects_path
[docs] def user_publicshare_path() -> Path: """:returns: public share path tied to the user""" return PlatformDirs().user_publicshare_path
[docs] def user_templates_path() -> Path: """:returns: templates path tied to the user""" return PlatformDirs().user_templates_path
[docs] def user_fonts_path() -> Path: """:returns: fonts path tied to the user""" return PlatformDirs().user_fonts_path
[docs] def user_preference_path() -> Path: """:returns: preference path tied to the user""" return PlatformDirs().user_preference_path
[docs] def user_bin_path() -> Path: """:returns: bin path tied to the user""" return PlatformDirs().user_bin_path
[docs] def site_bin_path() -> Path: """:returns: bin path shared by users""" return PlatformDirs().site_bin_path
[docs] def user_applications_path() -> Path: """:returns: applications path tied to the user""" return PlatformDirs().user_applications_path
[docs] def site_applications_path( multipath: bool = False, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> Path: """:param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: applications path shared by users """ return PlatformDirs( multipath=multipath, ensure_exists=ensure_exists, ).site_applications_path
[docs] def user_runtime_path( # noqa: PLR0913, PLR0917 appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 use_site_for_root: bool = False, # noqa: FBT001, FBT002 ) -> Path: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. :returns: runtime path tied to the user """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, opinion=opinion, ensure_exists=ensure_exists, use_site_for_root=use_site_for_root, ).user_runtime_path
[docs] def site_runtime_path( appname: str | None = None, appauthor: str | Literal[False] | None = None, version: str | None = None, opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> Path: """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: runtime path shared by users """ return PlatformDirs( appname=appname, appauthor=appauthor, version=version, opinion=opinion, ensure_exists=ensure_exists, ).site_runtime_path
__all__ = [ "AppDirs", "PlatformDirs", "PlatformDirsABC", "__version__", "__version_info__", "site_applications_dir", "site_applications_path", "site_bin_dir", "site_bin_path", "site_cache_dir", "site_cache_path", "site_config_dir", "site_config_path", "site_data_dir", "site_data_path", "site_log_dir", "site_log_path", "site_runtime_dir", "site_runtime_path", "site_state_dir", "site_state_path", "user_applications_dir", "user_applications_path", "user_bin_dir", "user_bin_path", "user_cache_dir", "user_cache_path", "user_config_dir", "user_config_path", "user_data_dir", "user_data_path", "user_desktop_dir", "user_desktop_path", "user_documents_dir", "user_documents_path", "user_downloads_dir", "user_downloads_path", "user_fonts_dir", "user_fonts_path", "user_log_dir", "user_log_path", "user_music_dir", "user_music_path", "user_pictures_dir", "user_pictures_path", "user_preference_dir", "user_preference_path", "user_projects_dir", "user_projects_path", "user_publicshare_dir", "user_publicshare_path", "user_runtime_dir", "user_runtime_path", "user_state_dir", "user_state_path", "user_templates_dir", "user_templates_path", "user_videos_dir", "user_videos_path", ]