diff options
| author | robot-piglet <[email protected]> | 2026-03-04 11:13:02 +0300 |
|---|---|---|
| committer | robot-piglet <[email protected]> | 2026-03-04 11:36:22 +0300 |
| commit | a15ae319a82adf197a277cc158045e5ef6c7f3cf (patch) | |
| tree | 671f4d16a7d230f456e9f65ec99617c83d1c7f9d /contrib/python/platformdirs | |
| parent | 2b06ac23aac9553bf888b5e0381b265fec151b37 (diff) | |
Intermediate changes
commit_hash:083d29cb596a0680d568e7e529be15d821cd3eb3
Diffstat (limited to 'contrib/python/platformdirs')
| -rw-r--r-- | contrib/python/platformdirs/.dist-info/METADATA | 2 | ||||
| -rw-r--r-- | contrib/python/platformdirs/platformdirs/__init__.py | 137 | ||||
| -rw-r--r-- | contrib/python/platformdirs/platformdirs/_xdg.py | 32 | ||||
| -rw-r--r-- | contrib/python/platformdirs/platformdirs/android.py | 72 | ||||
| -rw-r--r-- | contrib/python/platformdirs/platformdirs/api.py | 125 | ||||
| -rw-r--r-- | contrib/python/platformdirs/platformdirs/macos.py | 71 | ||||
| -rw-r--r-- | contrib/python/platformdirs/platformdirs/unix.py | 102 | ||||
| -rw-r--r-- | contrib/python/platformdirs/platformdirs/version.py | 4 | ||||
| -rw-r--r-- | contrib/python/platformdirs/platformdirs/windows.py | 69 | ||||
| -rw-r--r-- | contrib/python/platformdirs/ya.make | 2 |
10 files changed, 288 insertions, 328 deletions
diff --git a/contrib/python/platformdirs/.dist-info/METADATA b/contrib/python/platformdirs/.dist-info/METADATA index f3e2dcea219..c81c4f3a1fd 100644 --- a/contrib/python/platformdirs/.dist-info/METADATA +++ b/contrib/python/platformdirs/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.4 Name: platformdirs -Version: 4.9.1 +Version: 4.9.2 Summary: A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`. Project-URL: Changelog, https://platformdirs.readthedocs.io/en/latest/changelog.html Project-URL: Documentation, https://platformdirs.readthedocs.io diff --git a/contrib/python/platformdirs/platformdirs/__init__.py b/contrib/python/platformdirs/platformdirs/__init__.py index fb530c92998..4ab450ea953 100644 --- a/contrib/python/platformdirs/platformdirs/__init__.py +++ b/contrib/python/platformdirs/platformdirs/__init__.py @@ -1,8 +1,7 @@ -""" -Utilities for determining application-specific dirs. +"""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. +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. @@ -61,14 +60,15 @@ def user_data_dir( # noqa: PLR0913, PLR0917 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 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, @@ -87,13 +87,14 @@ def site_data_dir( multipath: bool = False, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> str: - """ - :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. + """: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, @@ -112,14 +113,15 @@ def user_config_dir( # noqa: PLR0913, PLR0917 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 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, @@ -138,13 +140,14 @@ def site_config_dir( multipath: bool = False, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> str: - """ - :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. + """: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, @@ -163,14 +166,15 @@ def user_cache_dir( # noqa: PLR0913, PLR0917 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 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, @@ -189,13 +193,14 @@ def site_cache_dir( opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> str: - """ - :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. + """: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, @@ -214,14 +219,15 @@ def user_state_dir( # noqa: PLR0913, PLR0917 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 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, @@ -239,12 +245,13 @@ def site_state_dir( version: str | None = None, ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> str: - """ - :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. + """: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, @@ -262,14 +269,15 @@ def user_log_dir( # noqa: PLR0913, PLR0917 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 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, @@ -288,13 +296,14 @@ def site_log_dir( opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> str: - """ - :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. + """: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, @@ -354,10 +363,11 @@ 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 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, @@ -373,14 +383,15 @@ def user_runtime_dir( # noqa: PLR0913, PLR0917 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 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, @@ -399,13 +410,14 @@ def site_runtime_dir( opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> str: - """ - :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. + """: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, @@ -424,14 +436,15 @@ def user_data_path( # noqa: PLR0913, PLR0917 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 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, @@ -450,13 +463,14 @@ def site_data_path( multipath: bool = False, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> Path: - """ - :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. + """: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, @@ -475,14 +489,15 @@ def user_config_path( # noqa: PLR0913, PLR0917 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 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, @@ -501,13 +516,14 @@ def site_config_path( multipath: bool = False, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> Path: - """ - :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. + """: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, @@ -525,13 +541,14 @@ def site_cache_path( opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> Path: - """ - :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. + """: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, @@ -550,14 +567,15 @@ def user_cache_path( # noqa: PLR0913, PLR0917 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 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, @@ -577,14 +595,15 @@ def user_state_path( # noqa: PLR0913, PLR0917 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 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, @@ -602,12 +621,13 @@ def site_state_path( version: str | None = None, ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> Path: - """ - :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. + """: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, @@ -625,14 +645,15 @@ def user_log_path( # noqa: PLR0913, PLR0917 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 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, @@ -651,13 +672,14 @@ def site_log_path( opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> Path: - """ - :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. + """: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, @@ -717,10 +739,11 @@ 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 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, @@ -736,14 +759,15 @@ def user_runtime_path( # noqa: PLR0913, PLR0917 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 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, @@ -762,13 +786,14 @@ def site_runtime_path( opinion: bool = True, # noqa: FBT001, FBT002 ensure_exists: bool = False, # noqa: FBT001, FBT002 ) -> Path: - """ - :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. + """: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, diff --git a/contrib/python/platformdirs/platformdirs/_xdg.py b/contrib/python/platformdirs/platformdirs/_xdg.py index 4060e89f434..c4aadd6d031 100644 --- a/contrib/python/platformdirs/platformdirs/_xdg.py +++ b/contrib/python/platformdirs/platformdirs/_xdg.py @@ -12,7 +12,7 @@ class XDGMixin(PlatformDirsABC): @property def user_data_dir(self) -> str: - """:return: data directory tied to the user, from ``$XDG_DATA_HOME`` if set, else platform default""" + """:returns: data directory tied to the user, from ``$XDG_DATA_HOME`` if set, else platform default""" if path := os.environ.get("XDG_DATA_HOME", "").strip(): return self._append_app_name_and_version(path) return super().user_data_dir @@ -25,13 +25,13 @@ class XDGMixin(PlatformDirsABC): @property def site_data_dir(self) -> str: - """:return: data directories shared by users, from ``$XDG_DATA_DIRS`` if set, else platform default""" + """:returns: data directories shared by users, from ``$XDG_DATA_DIRS`` if set, else platform default""" dirs = self._site_data_dirs return os.pathsep.join(dirs) if self.multipath else dirs[0] @property def user_config_dir(self) -> str: - """:return: config directory tied to the user, from ``$XDG_CONFIG_HOME`` if set, else platform default""" + """:returns: config directory tied to the user, from ``$XDG_CONFIG_HOME`` if set, else platform default""" if path := os.environ.get("XDG_CONFIG_HOME", "").strip(): return self._append_app_name_and_version(path) return super().user_config_dir @@ -44,83 +44,83 @@ class XDGMixin(PlatformDirsABC): @property def site_config_dir(self) -> str: - """:return: config directories shared by users, from ``$XDG_CONFIG_DIRS`` if set, else platform default""" + """:returns: config directories shared by users, from ``$XDG_CONFIG_DIRS`` if set, else platform default""" dirs = self._site_config_dirs return os.pathsep.join(dirs) if self.multipath else dirs[0] @property def user_cache_dir(self) -> str: - """:return: cache directory tied to the user, from ``$XDG_CACHE_HOME`` if set, else platform default""" + """:returns: cache directory tied to the user, from ``$XDG_CACHE_HOME`` if set, else platform default""" if path := os.environ.get("XDG_CACHE_HOME", "").strip(): return self._append_app_name_and_version(path) return super().user_cache_dir @property def user_state_dir(self) -> str: - """:return: state directory tied to the user, from ``$XDG_STATE_HOME`` if set, else platform default""" + """:returns: state directory tied to the user, from ``$XDG_STATE_HOME`` if set, else platform default""" if path := os.environ.get("XDG_STATE_HOME", "").strip(): return self._append_app_name_and_version(path) return super().user_state_dir @property def user_runtime_dir(self) -> str: - """:return: runtime directory tied to the user, from ``$XDG_RUNTIME_DIR`` if set, else platform default""" + """:returns: runtime directory tied to the user, from ``$XDG_RUNTIME_DIR`` if set, else platform default""" if path := os.environ.get("XDG_RUNTIME_DIR", "").strip(): return self._append_app_name_and_version(path) return super().user_runtime_dir @property def site_runtime_dir(self) -> str: - """:return: runtime directory shared by users, from ``$XDG_RUNTIME_DIR`` if set, else platform default""" + """:returns: runtime directory shared by users, from ``$XDG_RUNTIME_DIR`` if set, else platform default""" if path := os.environ.get("XDG_RUNTIME_DIR", "").strip(): return self._append_app_name_and_version(path) return super().site_runtime_dir @property def user_documents_dir(self) -> str: - """:return: documents directory tied to the user, from ``$XDG_DOCUMENTS_DIR`` if set, else platform default""" + """:returns: documents directory tied to the user, from ``$XDG_DOCUMENTS_DIR`` if set, else platform default""" if path := os.environ.get("XDG_DOCUMENTS_DIR", "").strip(): return os.path.expanduser(path) # noqa: PTH111 return super().user_documents_dir @property def user_downloads_dir(self) -> str: - """:return: downloads directory tied to the user, from ``$XDG_DOWNLOAD_DIR`` if set, else platform default""" + """:returns: downloads directory tied to the user, from ``$XDG_DOWNLOAD_DIR`` if set, else platform default""" if path := os.environ.get("XDG_DOWNLOAD_DIR", "").strip(): return os.path.expanduser(path) # noqa: PTH111 return super().user_downloads_dir @property def user_pictures_dir(self) -> str: - """:return: pictures directory tied to the user, from ``$XDG_PICTURES_DIR`` if set, else platform default""" + """:returns: pictures directory tied to the user, from ``$XDG_PICTURES_DIR`` if set, else platform default""" if path := os.environ.get("XDG_PICTURES_DIR", "").strip(): return os.path.expanduser(path) # noqa: PTH111 return super().user_pictures_dir @property def user_videos_dir(self) -> str: - """:return: videos directory tied to the user, from ``$XDG_VIDEOS_DIR`` if set, else platform default""" + """:returns: videos directory tied to the user, from ``$XDG_VIDEOS_DIR`` if set, else platform default""" if path := os.environ.get("XDG_VIDEOS_DIR", "").strip(): return os.path.expanduser(path) # noqa: PTH111 return super().user_videos_dir @property def user_music_dir(self) -> str: - """:return: music directory tied to the user, from ``$XDG_MUSIC_DIR`` if set, else platform default""" + """:returns: music directory tied to the user, from ``$XDG_MUSIC_DIR`` if set, else platform default""" if path := os.environ.get("XDG_MUSIC_DIR", "").strip(): return os.path.expanduser(path) # noqa: PTH111 return super().user_music_dir @property def user_desktop_dir(self) -> str: - """:return: desktop directory tied to the user, from ``$XDG_DESKTOP_DIR`` if set, else platform default""" + """:returns: desktop directory tied to the user, from ``$XDG_DESKTOP_DIR`` if set, else platform default""" if path := os.environ.get("XDG_DESKTOP_DIR", "").strip(): return os.path.expanduser(path) # noqa: PTH111 return super().user_desktop_dir @property def user_applications_dir(self) -> str: - """:return: applications directory tied to the user, from ``$XDG_DATA_HOME`` if set, else platform default""" + """:returns: applications directory tied to the user, from ``$XDG_DATA_HOME`` if set, else platform default""" if path := os.environ.get("XDG_DATA_HOME", "").strip(): return os.path.join(os.path.expanduser(path), "applications") # noqa: PTH111, PTH118 return super().user_applications_dir @@ -133,7 +133,7 @@ class XDGMixin(PlatformDirsABC): @property def site_applications_dir(self) -> str: - """:return: applications directories shared by users, from ``$XDG_DATA_DIRS`` if set, else platform default""" + """:returns: applications directories shared by users, from ``$XDG_DATA_DIRS`` if set, else platform default""" dirs = self._site_applications_dirs return os.pathsep.join(dirs) if self.multipath else dirs[0] diff --git a/contrib/python/platformdirs/platformdirs/android.py b/contrib/python/platformdirs/platformdirs/android.py index 708355bf1a8..38243dfc96a 100644 --- a/contrib/python/platformdirs/platformdirs/android.py +++ b/contrib/python/platformdirs/platformdirs/android.py @@ -12,67 +12,60 @@ from .api import PlatformDirsABC class Android(PlatformDirsABC): # noqa: PLR0904 - """ - Platform directories for Android. + """Platform directories for Android. Follows the guidance `from here <https://android.stackexchange.com/a/216132>`_. Directories are typically located under the app's private storage (``/data/user/<userid>/<packagename>/``). Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`, `version - <platformdirs.api.PlatformDirsABC.version>`, `opinion <platformdirs.api.PlatformDirsABC.opinion>`, - `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. + <platformdirs.api.PlatformDirsABC.version>`, `opinion <platformdirs.api.PlatformDirsABC.opinion>`, `ensure_exists + <platformdirs.api.PlatformDirsABC.ensure_exists>`. """ @property def user_data_dir(self) -> str: - """:return: data directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/files/<AppName>``""" + """:returns: data directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/files/<AppName>``""" return self._append_app_name_and_version(cast("str", _android_folder()), "files") @property def site_data_dir(self) -> str: - """:return: data directory shared by users, same as `user_data_dir`""" + """:returns: data directory shared by users, same as `user_data_dir`""" return self.user_data_dir @property def user_config_dir(self) -> str: - """ - :return: config directory tied to the user, e.g. \ - ``/data/user/<userid>/<packagename>/shared_prefs/<AppName>`` - """ + """:returns: config directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/shared_prefs/<AppName>``""" return self._append_app_name_and_version(cast("str", _android_folder()), "shared_prefs") @property def site_config_dir(self) -> str: - """:return: config directory shared by users, same as `user_config_dir`""" + """:returns: config directory shared by users, same as `user_config_dir`""" return self.user_config_dir @property def user_cache_dir(self) -> str: - """:return: cache directory tied to the user, e.g.,``/data/user/<userid>/<packagename>/cache/<AppName>``""" + """:returns: cache directory tied to the user, e.g.,``/data/user/<userid>/<packagename>/cache/<AppName>``""" return self._append_app_name_and_version(cast("str", _android_folder()), "cache") @property def site_cache_dir(self) -> str: - """:return: cache directory shared by users, same as `user_cache_dir`""" + """:returns: cache directory shared by users, same as `user_cache_dir`""" return self.user_cache_dir @property def user_state_dir(self) -> str: - """:return: state directory tied to the user, same as `user_data_dir`""" + """:returns: state directory tied to the user, same as `user_data_dir`""" return self.user_data_dir @property def site_state_dir(self) -> str: - """:return: state directory shared by users, same as `user_state_dir`""" + """:returns: state directory shared by users, same as `user_state_dir`""" return self.user_state_dir @property def user_log_dir(self) -> str: - """ - :return: log directory tied to the user, same as `user_cache_dir` if not opinionated else ``log`` in it, - e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>/log`` - """ + """:returns: log directory tied to the user, same as `user_cache_dir` if not opinionated else ``log`` in it, e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>/log``""" path = self.user_cache_dir if self.opinion: path = os.path.join(path, "log") # noqa: PTH118 @@ -80,65 +73,62 @@ class Android(PlatformDirsABC): # noqa: PLR0904 @property def site_log_dir(self) -> str: - """:return: log directory shared by users, same as `user_log_dir`""" + """:returns: log directory shared by users, same as `user_log_dir`""" return self.user_log_dir @property def user_documents_dir(self) -> str: - """:return: documents directory tied to the user e.g. ``/storage/emulated/0/Documents``""" + """:returns: documents directory tied to the user e.g. ``/storage/emulated/0/Documents``""" return _android_documents_folder() @property def user_downloads_dir(self) -> str: - """:return: downloads directory tied to the user e.g. ``/storage/emulated/0/Downloads``""" + """:returns: downloads directory tied to the user e.g. ``/storage/emulated/0/Downloads``""" return _android_downloads_folder() @property def user_pictures_dir(self) -> str: - """:return: pictures directory tied to the user e.g. ``/storage/emulated/0/Pictures``""" + """:returns: pictures directory tied to the user e.g. ``/storage/emulated/0/Pictures``""" return _android_pictures_folder() @property def user_videos_dir(self) -> str: - """:return: videos directory tied to the user e.g. ``/storage/emulated/0/DCIM/Camera``""" + """:returns: videos directory tied to the user e.g. ``/storage/emulated/0/DCIM/Camera``""" return _android_videos_folder() @property def user_music_dir(self) -> str: - """:return: music directory tied to the user e.g. ``/storage/emulated/0/Music``""" + """:returns: music directory tied to the user e.g. ``/storage/emulated/0/Music``""" return _android_music_folder() @property def user_desktop_dir(self) -> str: - """:return: desktop directory tied to the user e.g. ``/storage/emulated/0/Desktop``""" + """:returns: desktop directory tied to the user e.g. ``/storage/emulated/0/Desktop``""" return "/storage/emulated/0/Desktop" @property def user_bin_dir(self) -> str: - """:return: bin directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/files/bin``""" + """:returns: bin directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/files/bin``""" return os.path.join(cast("str", _android_folder()), "files", "bin") # noqa: PTH118 @property def site_bin_dir(self) -> str: - """:return: bin directory shared by users, same as `user_bin_dir`""" + """:returns: bin directory shared by users, same as `user_bin_dir`""" return self.user_bin_dir @property def user_applications_dir(self) -> str: - """:return: applications directory tied to the user, same as `user_data_dir`""" + """:returns: applications directory tied to the user, same as `user_data_dir`""" return self.user_data_dir @property def site_applications_dir(self) -> str: - """:return: applications directory shared by users, same as `user_applications_dir`""" + """:returns: applications directory shared by users, same as `user_applications_dir`""" return self.user_applications_dir @property def user_runtime_dir(self) -> str: - """ - :return: runtime directory tied to the user, same as `user_cache_dir` if not opinionated else ``tmp`` in it, - e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>/tmp`` - """ + """:returns: runtime directory tied to the user, same as `user_cache_dir` if not opinionated else ``tmp`` in it, e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>/tmp``""" path = self.user_cache_dir if self.opinion: path = os.path.join(path, "tmp") # noqa: PTH118 @@ -146,13 +136,13 @@ class Android(PlatformDirsABC): # noqa: PLR0904 @property def site_runtime_dir(self) -> str: - """:return: runtime directory shared by users, same as `user_runtime_dir`""" + """:returns: runtime directory shared by users, same as `user_runtime_dir`""" return self.user_runtime_dir @lru_cache(maxsize=1) def _android_folder() -> str | None: # noqa: C901 - """:return: base folder for the Android OS or None if it cannot be found""" + """:returns: base folder for the Android OS or None if it cannot be found""" result: str | None = None # type checker isn't happy with our "import android", just don't do this when type checking see # https://stackoverflow.com/a/61394121 @@ -200,7 +190,7 @@ def _android_folder() -> str | None: # noqa: C901 @lru_cache(maxsize=1) def _android_documents_folder() -> str: - """:return: documents folder for the Android OS""" + """:returns: documents folder for the Android OS""" # Get directories with pyjnius try: from jnius import autoclass # noqa: PLC0415 # ty: ignore[unresolved-import] @@ -216,7 +206,7 @@ def _android_documents_folder() -> str: @lru_cache(maxsize=1) def _android_downloads_folder() -> str: - """:return: downloads folder for the Android OS""" + """:returns: downloads folder for the Android OS""" # Get directories with pyjnius try: from jnius import autoclass # noqa: PLC0415 # ty: ignore[unresolved-import] @@ -232,7 +222,7 @@ def _android_downloads_folder() -> str: @lru_cache(maxsize=1) def _android_pictures_folder() -> str: - """:return: pictures folder for the Android OS""" + """:returns: pictures folder for the Android OS""" # Get directories with pyjnius try: from jnius import autoclass # noqa: PLC0415 # ty: ignore[unresolved-import] @@ -248,7 +238,7 @@ def _android_pictures_folder() -> str: @lru_cache(maxsize=1) def _android_videos_folder() -> str: - """:return: videos folder for the Android OS""" + """:returns: videos folder for the Android OS""" # Get directories with pyjnius try: from jnius import autoclass # noqa: PLC0415 # ty: ignore[unresolved-import] @@ -264,7 +254,7 @@ def _android_videos_folder() -> str: @lru_cache(maxsize=1) def _android_music_folder() -> str: - """:return: music folder for the Android OS""" + """:returns: music folder for the Android OS""" # Get directories with pyjnius try: from jnius import autoclass # noqa: PLC0415 # ty: ignore[unresolved-import] diff --git a/contrib/python/platformdirs/platformdirs/api.py b/contrib/python/platformdirs/platformdirs/api.py index 46afe0a82f8..1ee29adb5be 100644 --- a/contrib/python/platformdirs/platformdirs/api.py +++ b/contrib/python/platformdirs/platformdirs/api.py @@ -13,13 +13,11 @@ if TYPE_CHECKING: class PlatformDirsABC(ABC): # noqa: PLR0904 - """ - Abstract base class defining all platform directory properties, their :class:`~pathlib.Path` variants, and - iterators. + """Abstract base class defining all platform directory properties, their :class:`~pathlib.Path` variants, and iterators. - Platform-specific subclasses (e.g. :class:`~platformdirs.windows.Windows`, - :class:`~platformdirs.macos.MacOS`, :class:`~platformdirs.unix.Unix`) implement the abstract - properties to return the appropriate paths for each operating system. + Platform-specific subclasses (e.g. :class:`~platformdirs.windows.Windows`, :class:`~platformdirs.macos.MacOS`, + :class:`~platformdirs.unix.Unix`) implement the abstract properties to return the appropriate paths for each + operating system. """ @@ -34,8 +32,7 @@ class PlatformDirsABC(ABC): # noqa: PLR0904 ensure_exists: bool = False, # noqa: FBT001, FBT002 use_site_for_root: bool = False, # noqa: FBT001, FBT002 ) -> None: - """ - Create a new platform directory. + """Create a new platform directory. :param appname: See `appname`. :param appauthor: See `appauthor`. @@ -49,55 +46,47 @@ class PlatformDirsABC(ABC): # noqa: PLR0904 """ self.appname = appname #: The name of the application. self.appauthor = appauthor - """ - The name of the app author or distributing body for this application. + """The name of the app author or distributing body for this application. Typically, it is the owning company name. Defaults to `appname`. You may pass ``False`` to disable it. """ self.version = version - """ - An optional version path element to append to the path. + """An optional version path element to append to the path. You might want to use this if you want multiple versions of your app to be able to run independently. If used, this would typically be ``<major>.<minor>``. """ self.roaming = roaming - """ - Whether to use the roaming appdata directory on Windows. + """Whether to use the roaming appdata directory on Windows. That means that for users on a Windows network setup for roaming profiles, this user data will be synced on - login (see - `here <https://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>`_). + login (see `here <https://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>`_). """ self.multipath = multipath - """ - An optional parameter which indicates that the entire list of data dirs should be returned. + """An optional parameter which indicates that the entire list of data dirs should be returned. By default, the first item would only be returned. Only affects ``site_data_dir`` and ``site_config_dir`` on Unix and macOS. """ self.opinion = opinion - """ - Whether to use opinionated values. + """Whether to use opinionated values. When enabled, appends an additional subdirectory for certain directories: e.g. ``Cache`` for cache and ``Logs`` for logs on Windows, ``log`` for logs on Unix. """ self.ensure_exists = ensure_exists - """ - Optionally create the directory (and any missing parents) upon access if it does not exist. + """Optionally create the directory (and any missing parents) upon access if it does not exist. By default, no directories are created. """ self.use_site_for_root = use_site_for_root - """ - Whether to redirect ``user_*_dir`` calls to their ``site_*_dir`` equivalents when running as root (uid 0). + """Whether to redirect ``user_*_dir`` calls to their ``site_*_dir`` equivalents when running as root (uid 0). Only has an effect on Unix. Disabled by default for backwards compatibility. When enabled, XDG user environment variables (e.g. ``XDG_DATA_HOME``) are bypassed for the redirected directories. @@ -127,221 +116,221 @@ class PlatformDirsABC(ABC): # noqa: PLR0904 @property @abstractmethod def user_data_dir(self) -> str: - """:return: data directory tied to the user""" + """:returns: data directory tied to the user""" @property @abstractmethod def site_data_dir(self) -> str: - """:return: data directory shared by users""" + """:returns: data directory shared by users""" @property @abstractmethod def user_config_dir(self) -> str: - """:return: config directory tied to the user""" + """:returns: config directory tied to the user""" @property @abstractmethod def site_config_dir(self) -> str: - """:return: config directory shared by users""" + """:returns: config directory shared by users""" @property @abstractmethod def user_cache_dir(self) -> str: - """:return: cache directory tied to the user""" + """:returns: cache directory tied to the user""" @property @abstractmethod def site_cache_dir(self) -> str: - """:return: cache directory shared by users""" + """:returns: cache directory shared by users""" @property @abstractmethod def user_state_dir(self) -> str: - """:return: state directory tied to the user""" + """:returns: state directory tied to the user""" @property @abstractmethod def site_state_dir(self) -> str: - """:return: state directory shared by users""" + """:returns: state directory shared by users""" @property @abstractmethod def user_log_dir(self) -> str: - """:return: log directory tied to the user""" + """:returns: log directory tied to the user""" @property @abstractmethod def site_log_dir(self) -> str: - """:return: log directory shared by users""" + """:returns: log directory shared by users""" @property @abstractmethod def user_documents_dir(self) -> str: - """:return: documents directory tied to the user""" + """:returns: documents directory tied to the user""" @property @abstractmethod def user_downloads_dir(self) -> str: - """:return: downloads directory tied to the user""" + """:returns: downloads directory tied to the user""" @property @abstractmethod def user_pictures_dir(self) -> str: - """:return: pictures directory tied to the user""" + """:returns: pictures directory tied to the user""" @property @abstractmethod def user_videos_dir(self) -> str: - """:return: videos directory tied to the user""" + """:returns: videos directory tied to the user""" @property @abstractmethod def user_music_dir(self) -> str: - """:return: music directory tied to the user""" + """:returns: music directory tied to the user""" @property @abstractmethod def user_desktop_dir(self) -> str: - """:return: desktop directory tied to the user""" + """:returns: desktop directory tied to the user""" @property @abstractmethod def user_bin_dir(self) -> str: - """:return: bin directory tied to the user""" + """:returns: bin directory tied to the user""" @property @abstractmethod def site_bin_dir(self) -> str: - """:return: bin directory shared by users""" + """:returns: bin directory shared by users""" @property @abstractmethod def user_applications_dir(self) -> str: - """:return: applications directory tied to the user""" + """:returns: applications directory tied to the user""" @property @abstractmethod def site_applications_dir(self) -> str: - """:return: applications directory shared by users""" + """:returns: applications directory shared by users""" @property @abstractmethod def user_runtime_dir(self) -> str: - """:return: runtime directory tied to the user""" + """:returns: runtime directory tied to the user""" @property @abstractmethod def site_runtime_dir(self) -> str: - """:return: runtime directory shared by users""" + """:returns: runtime directory shared by users""" @property def user_data_path(self) -> Path: - """:return: data path tied to the user""" + """:returns: data path tied to the user""" return Path(self.user_data_dir) @property def site_data_path(self) -> Path: - """:return: data path shared by users""" + """:returns: data path shared by users""" return Path(self.site_data_dir) @property def user_config_path(self) -> Path: - """:return: config path tied to the user""" + """:returns: config path tied to the user""" return Path(self.user_config_dir) @property def site_config_path(self) -> Path: - """:return: config path shared by users""" + """:returns: config path shared by users""" return Path(self.site_config_dir) @property def user_cache_path(self) -> Path: - """:return: cache path tied to the user""" + """:returns: cache path tied to the user""" return Path(self.user_cache_dir) @property def site_cache_path(self) -> Path: - """:return: cache path shared by users""" + """:returns: cache path shared by users""" return Path(self.site_cache_dir) @property def user_state_path(self) -> Path: - """:return: state path tied to the user""" + """:returns: state path tied to the user""" return Path(self.user_state_dir) @property def site_state_path(self) -> Path: - """:return: state path shared by users""" + """:returns: state path shared by users""" return Path(self.site_state_dir) @property def user_log_path(self) -> Path: - """:return: log path tied to the user""" + """:returns: log path tied to the user""" return Path(self.user_log_dir) @property def site_log_path(self) -> Path: - """:return: log path shared by users""" + """:returns: log path shared by users""" return Path(self.site_log_dir) @property def user_documents_path(self) -> Path: - """:return: documents path tied to the user""" + """:returns: documents path tied to the user""" return Path(self.user_documents_dir) @property def user_downloads_path(self) -> Path: - """:return: downloads path tied to the user""" + """:returns: downloads path tied to the user""" return Path(self.user_downloads_dir) @property def user_pictures_path(self) -> Path: - """:return: pictures path tied to the user""" + """:returns: pictures path tied to the user""" return Path(self.user_pictures_dir) @property def user_videos_path(self) -> Path: - """:return: videos path tied to the user""" + """:returns: videos path tied to the user""" return Path(self.user_videos_dir) @property def user_music_path(self) -> Path: - """:return: music path tied to the user""" + """:returns: music path tied to the user""" return Path(self.user_music_dir) @property def user_desktop_path(self) -> Path: - """:return: desktop path tied to the user""" + """:returns: desktop path tied to the user""" return Path(self.user_desktop_dir) @property def user_bin_path(self) -> Path: - """:return: bin path tied to the user""" + """:returns: bin path tied to the user""" return Path(self.user_bin_dir) @property def site_bin_path(self) -> Path: - """:return: bin path shared by users""" + """:returns: bin path shared by users""" return Path(self.site_bin_dir) @property def user_applications_path(self) -> Path: - """:return: applications path tied to the user""" + """:returns: applications path tied to the user""" return Path(self.user_applications_dir) @property def site_applications_path(self) -> Path: - """:return: applications path shared by users""" + """:returns: applications path shared by users""" return Path(self.site_applications_dir) @property def user_runtime_path(self) -> Path: - """:return: runtime path tied to the user""" + """:returns: runtime path tied to the user""" return Path(self.user_runtime_dir) @property def site_runtime_path(self) -> Path: - """:return: runtime path shared by users""" + """:returns: runtime path shared by users""" return Path(self.site_runtime_dir) def iter_config_dirs(self) -> Iterator[str]: diff --git a/contrib/python/platformdirs/platformdirs/macos.py b/contrib/python/platformdirs/platformdirs/macos.py index 3343a0bfffc..249324672b0 100644 --- a/contrib/python/platformdirs/platformdirs/macos.py +++ b/contrib/python/platformdirs/platformdirs/macos.py @@ -17,17 +17,17 @@ if TYPE_CHECKING: class _MacOSDefaults(PlatformDirsABC): # noqa: PLR0904 - """ - Default platform directories for macOS without XDG environment variable overrides. + """Default platform directories for macOS without XDG environment variable overrides. - Follows the guidance from - `Apple's File System Programming Guide <https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html>`_. + Follows the guidance from `Apple's File System Programming Guide + <https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html>`_. The XDG env var handling is in :class:`~platformdirs._xdg.XDGMixin`. + """ @property def user_data_dir(self) -> str: - """:return: data directory tied to the user, e.g. ``~/Library/Application Support/$appname/$version``""" + """:returns: data directory tied to the user, e.g. ``~/Library/Application Support/$appname/$version``""" return self._append_app_name_and_version(os.path.expanduser("~/Library/Application Support")) # noqa: PTH111 @property @@ -40,12 +40,12 @@ class _MacOSDefaults(PlatformDirsABC): # noqa: PLR0904 @property def site_data_path(self) -> Path: - """:return: data path shared by users. Only return the first item, even if ``multipath`` is set to ``True``""" + """:returns: data path shared by users. Only return the first item, even if ``multipath`` is set to ``True``""" return self._first_item_as_path_if_multipath(self.site_data_dir) @property def user_config_dir(self) -> str: - """:return: config directory tied to the user, same as `user_data_dir`""" + """:returns: config directory tied to the user, same as `user_data_dir`""" return self.user_data_dir @property @@ -54,19 +54,12 @@ class _MacOSDefaults(PlatformDirsABC): # noqa: PLR0904 @property def user_cache_dir(self) -> str: - """:return: cache directory tied to the user, e.g. ``~/Library/Caches/$appname/$version``""" + """:returns: cache directory tied to the user, e.g. ``~/Library/Caches/$appname/$version``""" return self._append_app_name_and_version(os.path.expanduser("~/Library/Caches")) # noqa: PTH111 @property def site_cache_dir(self) -> str: - """ - :return: cache directory shared by users, e.g. ``/Library/Caches/$appname/$version``. - If we're using a Python binary managed by `Homebrew <https://brew.sh>`_, the directory - will be under the Homebrew prefix, e.g. ``$homebrew_prefix/var/cache/$appname/$version``. - If `multipath <platformdirs.api.PlatformDirsABC.multipath>` is enabled, and we're in Homebrew, - the response is a multi-path string separated by ":", e.g. - ``$homebrew_prefix/var/cache/$appname/$version:/Library/Caches/$appname/$version`` - """ + """:returns: cache directory shared by users, e.g. ``/Library/Caches/$appname/$version``. If we're using a Python binary managed by `Homebrew <https://brew.sh>`_, the directory will be under the Homebrew prefix, e.g. ``$homebrew_prefix/var/cache/$appname/$version``. If `multipath <platformdirs.api.PlatformDirsABC.multipath>` is enabled, and we're in Homebrew, the response is a multi-path string separated by ":", e.g. ``$homebrew_prefix/var/cache/$appname/$version:/Library/Caches/$appname/$version``""" is_homebrew = "/opt/python" in sys.prefix homebrew_prefix = sys.prefix.split("/opt/python")[0] if is_homebrew else "" path_list = [self._append_app_name_and_version(f"{homebrew_prefix}/var/cache")] if is_homebrew else [] @@ -77,72 +70,72 @@ class _MacOSDefaults(PlatformDirsABC): # noqa: PLR0904 @property def site_cache_path(self) -> Path: - """:return: cache path shared by users. Only return the first item, even if ``multipath`` is set to ``True``""" + """:returns: cache path shared by users. Only return the first item, even if ``multipath`` is set to ``True``""" return self._first_item_as_path_if_multipath(self.site_cache_dir) @property def user_state_dir(self) -> str: - """:return: state directory tied to the user, same as `user_data_dir`""" + """:returns: state directory tied to the user, same as `user_data_dir`""" return self.user_data_dir @property def site_state_dir(self) -> str: - """:return: state directory shared by users, same as `site_data_dir`""" + """:returns: state directory shared by users, same as `site_data_dir`""" return self.site_data_dir @property def user_log_dir(self) -> str: - """:return: log directory tied to the user, e.g. ``~/Library/Logs/$appname/$version``""" + """:returns: log directory tied to the user, e.g. ``~/Library/Logs/$appname/$version``""" return self._append_app_name_and_version(os.path.expanduser("~/Library/Logs")) # noqa: PTH111 @property def site_log_dir(self) -> str: - """:return: log directory shared by users, e.g. ``/Library/Logs/$appname/$version``""" + """:returns: log directory shared by users, e.g. ``/Library/Logs/$appname/$version``""" return self._append_app_name_and_version("/Library/Logs") @property def user_documents_dir(self) -> str: - """:return: documents directory tied to the user, e.g. ``~/Documents``""" + """:returns: documents directory tied to the user, e.g. ``~/Documents``""" return os.path.expanduser("~/Documents") # noqa: PTH111 @property def user_downloads_dir(self) -> str: - """:return: downloads directory tied to the user, e.g. ``~/Downloads``""" + """:returns: downloads directory tied to the user, e.g. ``~/Downloads``""" return os.path.expanduser("~/Downloads") # noqa: PTH111 @property def user_pictures_dir(self) -> str: - """:return: pictures directory tied to the user, e.g. ``~/Pictures``""" + """:returns: pictures directory tied to the user, e.g. ``~/Pictures``""" return os.path.expanduser("~/Pictures") # noqa: PTH111 @property def user_videos_dir(self) -> str: - """:return: videos directory tied to the user, e.g. ``~/Movies``""" + """:returns: videos directory tied to the user, e.g. ``~/Movies``""" return os.path.expanduser("~/Movies") # noqa: PTH111 @property def user_music_dir(self) -> str: - """:return: music directory tied to the user, e.g. ``~/Music``""" + """:returns: music directory tied to the user, e.g. ``~/Music``""" return os.path.expanduser("~/Music") # noqa: PTH111 @property def user_desktop_dir(self) -> str: - """:return: desktop directory tied to the user, e.g. ``~/Desktop``""" + """:returns: desktop directory tied to the user, e.g. ``~/Desktop``""" return os.path.expanduser("~/Desktop") # noqa: PTH111 @property def user_bin_dir(self) -> str: - """:return: bin directory tied to the user, e.g. ``~/.local/bin``""" + """:returns: bin directory tied to the user, e.g. ``~/.local/bin``""" return os.path.expanduser("~/.local/bin") # noqa: PTH111 @property def site_bin_dir(self) -> str: - """:return: bin directory shared by users, e.g. ``/usr/local/bin``""" + """:returns: bin directory shared by users, e.g. ``/usr/local/bin``""" return "/usr/local/bin" @property def user_applications_dir(self) -> str: - """:return: applications directory tied to the user, e.g. ``~/Applications``""" + """:returns: applications directory tied to the user, e.g. ``~/Applications``""" return os.path.expanduser("~/Applications") # noqa: PTH111 @property @@ -151,18 +144,18 @@ class _MacOSDefaults(PlatformDirsABC): # noqa: PLR0904 @property def site_applications_dir(self) -> str: - """:return: applications directory shared by users, e.g. ``/Applications``""" + """:returns: applications directory shared by users, e.g. ``/Applications``""" dirs = self._site_applications_dirs return os.pathsep.join(dirs) if self.multipath else dirs[0] @property def user_runtime_dir(self) -> str: - """:return: runtime directory tied to the user, e.g. ``~/Library/Caches/TemporaryItems/$appname/$version``""" + """:returns: runtime directory tied to the user, e.g. ``~/Library/Caches/TemporaryItems/$appname/$version``""" return self._append_app_name_and_version(os.path.expanduser("~/Library/Caches/TemporaryItems")) # noqa: PTH111 @property def site_runtime_dir(self) -> str: - """:return: runtime directory shared by users, same as `user_runtime_dir`""" + """:returns: runtime directory shared by users, same as `user_runtime_dir`""" return self.user_runtime_dir def iter_config_dirs(self) -> Iterator[str]: @@ -177,14 +170,12 @@ class _MacOSDefaults(PlatformDirsABC): # noqa: PLR0904 class MacOS(XDGMixin, _MacOSDefaults): - """ - Platform directories for the macOS operating system. + """Platform directories for the macOS operating system. - Follows the guidance from - `Apple documentation <https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html>`_. - Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`, - `version <platformdirs.api.PlatformDirsABC.version>`, - `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. + Follows the guidance from `Apple documentation + <https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html>`_. + Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`, `version + <platformdirs.api.PlatformDirsABC.version>`, `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. XDG environment variables (e.g. ``$XDG_DATA_HOME``) are supported and take precedence over macOS defaults. diff --git a/contrib/python/platformdirs/platformdirs/unix.py b/contrib/python/platformdirs/platformdirs/unix.py index e388fcbd2d7..53cba338cb9 100644 --- a/contrib/python/platformdirs/platformdirs/unix.py +++ b/contrib/python/platformdirs/platformdirs/unix.py @@ -27,10 +27,10 @@ else: class _UnixDefaults(PlatformDirsABC): # noqa: PLR0904 - """ - Default directories for Unix/Linux without XDG environment variable overrides. + """Default directories for Unix/Linux without XDG environment variable overrides. The XDG env var handling is in :class:`~platformdirs._xdg.XDGMixin`. + """ @cached_property @@ -39,10 +39,7 @@ class _UnixDefaults(PlatformDirsABC): # noqa: PLR0904 @property def user_data_dir(self) -> str: - """ - :return: data directory tied to the user, e.g. ``~/.local/share/$appname/$version`` or - ``$XDG_DATA_HOME/$appname/$version`` - """ + """:returns: data directory tied to the user, e.g. ``~/.local/share/$appname/$version`` or ``$XDG_DATA_HOME/$appname/$version``""" return self._append_app_name_and_version(os.path.expanduser("~/.local/share")) # noqa: PTH111 @property @@ -51,10 +48,7 @@ class _UnixDefaults(PlatformDirsABC): # noqa: PLR0904 @property def user_config_dir(self) -> str: - """ - :return: config directory tied to the user, e.g. ``~/.config/$appname/$version`` or - ``$XDG_CONFIG_HOME/$appname/$version`` - """ + """:returns: config directory tied to the user, e.g. ``~/.config/$appname/$version`` or ``$XDG_CONFIG_HOME/$appname/$version``""" return self._append_app_name_and_version(os.path.expanduser("~/.config")) # noqa: PTH111 @property @@ -63,33 +57,27 @@ class _UnixDefaults(PlatformDirsABC): # noqa: PLR0904 @property def user_cache_dir(self) -> str: - """ - :return: cache directory tied to the user, e.g. ``~/.cache/$appname/$version`` or - ``$XDG_CACHE_HOME/$appname/$version`` - """ + """:returns: cache directory tied to the user, e.g. ``~/.cache/$appname/$version`` or ``$XDG_CACHE_HOME/$appname/$version``""" return self._append_app_name_and_version(os.path.expanduser("~/.cache")) # noqa: PTH111 @property def site_cache_dir(self) -> str: - """:return: cache directory shared by users, e.g. ``/var/cache/$appname/$version``""" + """:returns: cache directory shared by users, e.g. ``/var/cache/$appname/$version``""" return self._append_app_name_and_version("/var/cache") @property def user_state_dir(self) -> str: - """ - :return: state directory tied to the user, e.g. ``~/.local/state/$appname/$version`` or - ``$XDG_STATE_HOME/$appname/$version`` - """ + """:returns: state directory tied to the user, e.g. ``~/.local/state/$appname/$version`` or ``$XDG_STATE_HOME/$appname/$version``""" return self._append_app_name_and_version(os.path.expanduser("~/.local/state")) # noqa: PTH111 @property def site_state_dir(self) -> str: - """:return: state directory shared by users, e.g. ``/var/lib/$appname/$version``""" + """:returns: state directory shared by users, e.g. ``/var/lib/$appname/$version``""" return self._append_app_name_and_version("/var/lib") @property def user_log_dir(self) -> str: - """:return: log directory tied to the user, same as `user_state_dir` if not opinionated else ``log`` in it""" + """:returns: log directory tied to the user, same as `user_state_dir` if not opinionated else ``log`` in it""" path = self.user_state_dir if self.opinion: path = os.path.join(path, "log") # noqa: PTH118 @@ -98,56 +86,56 @@ class _UnixDefaults(PlatformDirsABC): # noqa: PLR0904 @property def site_log_dir(self) -> str: - """ - :return: log directory shared by users, e.g. ``/var/log/$appname/$version`` + """:returns: log directory shared by users, e.g. ``/var/log/$appname/$version`` Unlike `user_log_dir`, ``opinion`` has no effect since ``/var/log`` is inherently a log directory. + """ return self._append_app_name_and_version("/var/log") @property def user_documents_dir(self) -> str: - """:return: documents directory tied to the user, e.g. ``~/Documents``""" + """:returns: documents directory tied to the user, e.g. ``~/Documents``""" return _get_user_media_dir("XDG_DOCUMENTS_DIR", "~/Documents") @property def user_downloads_dir(self) -> str: - """:return: downloads directory tied to the user, e.g. ``~/Downloads``""" + """:returns: downloads directory tied to the user, e.g. ``~/Downloads``""" return _get_user_media_dir("XDG_DOWNLOAD_DIR", "~/Downloads") @property def user_pictures_dir(self) -> str: - """:return: pictures directory tied to the user, e.g. ``~/Pictures``""" + """:returns: pictures directory tied to the user, e.g. ``~/Pictures``""" return _get_user_media_dir("XDG_PICTURES_DIR", "~/Pictures") @property def user_videos_dir(self) -> str: - """:return: videos directory tied to the user, e.g. ``~/Videos``""" + """:returns: videos directory tied to the user, e.g. ``~/Videos``""" return _get_user_media_dir("XDG_VIDEOS_DIR", "~/Videos") @property def user_music_dir(self) -> str: - """:return: music directory tied to the user, e.g. ``~/Music``""" + """:returns: music directory tied to the user, e.g. ``~/Music``""" return _get_user_media_dir("XDG_MUSIC_DIR", "~/Music") @property def user_desktop_dir(self) -> str: - """:return: desktop directory tied to the user, e.g. ``~/Desktop``""" + """:returns: desktop directory tied to the user, e.g. ``~/Desktop``""" return _get_user_media_dir("XDG_DESKTOP_DIR", "~/Desktop") @property def user_bin_dir(self) -> str: - """:return: bin directory tied to the user, e.g. ``~/.local/bin``""" + """:returns: bin directory tied to the user, e.g. ``~/.local/bin``""" return os.path.expanduser("~/.local/bin") # noqa: PTH111 @property def site_bin_dir(self) -> str: - """:return: bin directory shared by users, e.g. ``/usr/local/bin``""" + """:returns: bin directory shared by users, e.g. ``/usr/local/bin``""" return "/usr/local/bin" @property def user_applications_dir(self) -> str: - """:return: applications directory tied to the user, e.g. ``~/.local/share/applications``""" + """:returns: applications directory tied to the user, e.g. ``~/.local/share/applications``""" return os.path.join(os.path.expanduser("~/.local/share"), "applications") # noqa: PTH111, PTH118 @property @@ -156,18 +144,16 @@ class _UnixDefaults(PlatformDirsABC): # noqa: PLR0904 @property def site_applications_dir(self) -> str: - """:return: applications directory shared by users, e.g. ``/usr/share/applications``""" + """:returns: applications directory shared by users, e.g. ``/usr/share/applications``""" dirs = self._site_applications_dirs return os.pathsep.join(dirs) if self.multipath else dirs[0] @property def user_runtime_dir(self) -> str: - """ - :return: runtime directory tied to the user, e.g. ``$XDG_RUNTIME_DIR/$appname/$version``. + """:returns: runtime directory tied to the user, e.g. ``$XDG_RUNTIME_DIR/$appname/$version``. + + If ``$XDG_RUNTIME_DIR`` is unset, tries the platform default (``/tmp/run/user/$(id -u)`` on OpenBSD, ``/var/run/user/$(id -u)`` on FreeBSD/NetBSD, ``/run/user/$(id -u)`` otherwise). If the default is not writable, falls back to a temporary directory. - If ``$XDG_RUNTIME_DIR`` is unset, tries the platform default (``/tmp/run/user/$(id -u)`` on - OpenBSD, ``/var/run/user/$(id -u)`` on FreeBSD/NetBSD, ``/run/user/$(id -u)`` otherwise). - If the default is not writable, falls back to a temporary directory. """ if sys.platform.startswith("openbsd"): path = f"/tmp/run/user/{getuid()}" # noqa: S108 @@ -181,17 +167,14 @@ class _UnixDefaults(PlatformDirsABC): # noqa: PLR0904 @property def site_runtime_dir(self) -> str: - """ - :return: runtime directory shared by users, e.g. ``/run/$appname/$version`` or \ - ``$XDG_RUNTIME_DIR/$appname/$version``. + """:returns: runtime directory shared by users, e.g. ``/run/$appname/$version`` or ``$XDG_RUNTIME_DIR/$appname/$version``. - Note that this behaves almost exactly like `user_runtime_dir` if ``$XDG_RUNTIME_DIR`` is set, but will - fall back to paths associated to the root user instead of a regular logged-in user if it's not set. + Note that this behaves almost exactly like `user_runtime_dir` if ``$XDG_RUNTIME_DIR`` is set, but will fall back to paths associated to the root user instead of a regular logged-in user if it's not set. - If you wish to ensure that a logged-in root user path is returned e.g. ``/run/user/0``, use `user_runtime_dir` - instead. + If you wish to ensure that a logged-in root user path is returned e.g. ``/run/user/0``, use `user_runtime_dir` instead. For FreeBSD/OpenBSD/NetBSD, it would return ``/var/run/$appname/$version`` if ``$XDG_RUNTIME_DIR`` is not set. + """ if sys.platform.startswith(("freebsd", "openbsd", "netbsd")): path = "/var/run" @@ -201,17 +184,17 @@ class _UnixDefaults(PlatformDirsABC): # noqa: PLR0904 @property def site_data_path(self) -> Path: - """:return: data path shared by users. Only return the first item, even if ``multipath`` is set to ``True``""" + """:returns: data path shared by users. Only return the first item, even if ``multipath`` is set to ``True``""" return self._first_item_as_path_if_multipath(self.site_data_dir) @property def site_config_path(self) -> Path: - """:return: config path shared by users, returns the first item, even if ``multipath`` is set to ``True``""" + """:returns: config path shared by users, returns the first item, even if ``multipath`` is set to ``True``""" return self._first_item_as_path_if_multipath(self.site_config_dir) @property def site_cache_path(self) -> Path: - """:return: cache path shared by users. Only return the first item, even if ``multipath`` is set to ``True``""" + """:returns: cache path shared by users. Only return the first item, even if ``multipath`` is set to ``True``""" return self._first_item_as_path_if_multipath(self.site_cache_dir) def iter_config_dirs(self) -> Iterator[str]: @@ -226,54 +209,54 @@ class _UnixDefaults(PlatformDirsABC): # noqa: PLR0904 class Unix(XDGMixin, _UnixDefaults): - """ - On Unix/Linux, we follow the `XDG Basedir Spec <https://specifications.freedesktop.org/basedir/latest/>`_. + """On Unix/Linux, we follow the `XDG Basedir Spec <https://specifications.freedesktop.org/basedir/latest/>`_. The spec allows overriding directories with environment variables. The examples shown are the default values, alongside the name of the environment variable that overrides them. Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`, `version <platformdirs.api.PlatformDirsABC.version>`, `multipath <platformdirs.api.PlatformDirsABC.multipath>`, `opinion <platformdirs.api.PlatformDirsABC.opinion>`, `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. + """ @property def user_data_dir(self) -> str: - """:return: data directory tied to the user, or site equivalent when root with ``use_site_for_root``""" + """:returns: data directory tied to the user, or site equivalent when root with ``use_site_for_root``""" return self.site_data_dir if self._use_site else super().user_data_dir @property def user_config_dir(self) -> str: - """:return: config directory tied to the user, or site equivalent when root with ``use_site_for_root``""" + """:returns: config directory tied to the user, or site equivalent when root with ``use_site_for_root``""" return self.site_config_dir if self._use_site else super().user_config_dir @property def user_cache_dir(self) -> str: - """:return: cache directory tied to the user, or site equivalent when root with ``use_site_for_root``""" + """:returns: cache directory tied to the user, or site equivalent when root with ``use_site_for_root``""" return self.site_cache_dir if self._use_site else super().user_cache_dir @property def user_state_dir(self) -> str: - """:return: state directory tied to the user, or site equivalent when root with ``use_site_for_root``""" + """:returns: state directory tied to the user, or site equivalent when root with ``use_site_for_root``""" return self.site_state_dir if self._use_site else super().user_state_dir @property def user_log_dir(self) -> str: - """:return: log directory tied to the user, or site equivalent when root with ``use_site_for_root``""" + """:returns: log directory tied to the user, or site equivalent when root with ``use_site_for_root``""" return self.site_log_dir if self._use_site else super().user_log_dir @property def user_applications_dir(self) -> str: - """:return: applications directory tied to the user, or site equivalent when root with ``use_site_for_root``""" + """:returns: applications directory tied to the user, or site equivalent when root with ``use_site_for_root``""" return self.site_applications_dir if self._use_site else super().user_applications_dir @property def user_runtime_dir(self) -> str: - """:return: runtime directory tied to the user, or site equivalent when root with ``use_site_for_root``""" + """:returns: runtime directory tied to the user, or site equivalent when root with ``use_site_for_root``""" return self.site_runtime_dir if self._use_site else super().user_runtime_dir @property def user_bin_dir(self) -> str: - """:return: bin directory tied to the user, or site equivalent when root with ``use_site_for_root``""" + """:returns: bin directory tied to the user, or site equivalent when root with ``use_site_for_root``""" return self.site_bin_dir if self._use_site else super().user_bin_dir @@ -284,8 +267,7 @@ def _get_user_media_dir(env_var: str, fallback_tilde_path: str) -> str: def _get_user_dirs_folder(key: str) -> str | None: - """ - Return directory from user-dirs.dirs config file. + """Return directory from user-dirs.dirs config file. See https://freedesktop.org/wiki/Software/xdg-user-dirs/. diff --git a/contrib/python/platformdirs/platformdirs/version.py b/contrib/python/platformdirs/platformdirs/version.py index 1ad854cdb25..db2fb3f4924 100644 --- a/contrib/python/platformdirs/platformdirs/version.py +++ b/contrib/python/platformdirs/platformdirs/version.py @@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE commit_id: COMMIT_ID __commit_id__: COMMIT_ID -__version__ = version = '4.9.1' -__version_tuple__ = version_tuple = (4, 9, 1) +__version__ = version = '4.9.2' +__version_tuple__ = version_tuple = (4, 9, 2) __commit_id__ = commit_id = None diff --git a/contrib/python/platformdirs/platformdirs/windows.py b/contrib/python/platformdirs/platformdirs/windows.py index 84afaa75565..47403dea5ef 100644 --- a/contrib/python/platformdirs/platformdirs/windows.py +++ b/contrib/python/platformdirs/platformdirs/windows.py @@ -16,8 +16,7 @@ _KF_FLAG_DONT_VERIFY: Final[int] = 0x00004000 class Windows(PlatformDirsABC): # noqa: PLR0904 - """ - `MSDN on where to store app data files <https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid>`_. + """`MSDN on where to store app data files <https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid>`_. Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`, `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`, `version <platformdirs.api.PlatformDirsABC.version>`, `roaming @@ -28,11 +27,7 @@ class Windows(PlatformDirsABC): # noqa: PLR0904 @property def user_data_dir(self) -> str: - """ - :return: data directory tied to the user, e.g. - ``%USERPROFILE%\\AppData\\Local\\$appauthor\\$appname`` (not roaming) or - ``%USERPROFILE%\\AppData\\Roaming\\$appauthor\\$appname`` (roaming) - """ + r""":returns: data directory tied to the user, e.g. ``%USERPROFILE%\AppData\Local\$appauthor\$appname`` (not roaming) or ``%USERPROFILE%\AppData\Roaming\$appauthor\$appname`` (roaming)""" const = "CSIDL_APPDATA" if self.roaming else "CSIDL_LOCAL_APPDATA" path = os.path.normpath(get_win_folder(const)) return self._append_parts(path) @@ -54,48 +49,45 @@ class Windows(PlatformDirsABC): # noqa: PLR0904 @property def site_data_dir(self) -> str: - """:return: data directory shared by users, e.g. ``C:\\ProgramData\\$appauthor\\$appname``""" + r""":returns: data directory shared by users, e.g. ``C:\ProgramData\$appauthor\$appname``""" path = os.path.normpath(get_win_folder("CSIDL_COMMON_APPDATA")) return self._append_parts(path) @property def user_config_dir(self) -> str: - """:return: config directory tied to the user, same as `user_data_dir`""" + """:returns: config directory tied to the user, same as `user_data_dir`""" return self.user_data_dir @property def site_config_dir(self) -> str: - """:return: config directory shared by users, same as `site_data_dir`""" + """:returns: config directory shared by users, same as `site_data_dir`""" return self.site_data_dir @property def user_cache_dir(self) -> str: - """ - :return: cache directory tied to the user (if opinionated with ``Cache`` folder within ``$appname``) e.g. - ``%USERPROFILE%\\AppData\\Local\\$appauthor\\$appname\\Cache\\$version`` - """ + r""":returns: cache directory tied to the user (if opinionated with ``Cache`` folder within ``$appname``) e.g. ``%USERPROFILE%\AppData\Local\$appauthor\$appname\Cache\$version``""" path = os.path.normpath(get_win_folder("CSIDL_LOCAL_APPDATA")) return self._append_parts(path, opinion_value="Cache") @property def site_cache_dir(self) -> str: - """:return: cache directory shared by users, e.g. ``C:\\ProgramData\\$appauthor\\$appname\\Cache\\$version``""" + r""":returns: cache directory shared by users, e.g. ``C:\ProgramData\$appauthor\$appname\Cache\$version``""" path = os.path.normpath(get_win_folder("CSIDL_COMMON_APPDATA")) return self._append_parts(path, opinion_value="Cache") @property def user_state_dir(self) -> str: - """:return: state directory tied to the user, same as `user_data_dir`""" + """:returns: state directory tied to the user, same as `user_data_dir`""" return self.user_data_dir @property def site_state_dir(self) -> str: - """:return: state directory shared by users, same as `site_data_dir`""" + """:returns: state directory shared by users, same as `site_data_dir`""" return self.site_data_dir @property def user_log_dir(self) -> str: - """:return: log directory tied to the user, same as `user_data_dir` if not opinionated else ``Logs`` in it""" + """:returns: log directory tied to the user, same as `user_data_dir` if not opinionated else ``Logs`` in it""" path = self.user_data_dir if self.opinion: path = os.path.join(path, "Logs") # noqa: PTH118 @@ -104,7 +96,7 @@ class Windows(PlatformDirsABC): # noqa: PLR0904 @property def site_log_dir(self) -> str: - """:return: log directory shared by users, same as `site_data_dir` if not opinionated else ``Logs`` in it""" + """:returns: log directory shared by users, same as `site_data_dir` if not opinionated else ``Logs`` in it""" path = self.site_data_dir if self.opinion: path = os.path.join(path, "Logs") # noqa: PTH118 @@ -113,69 +105,63 @@ class Windows(PlatformDirsABC): # noqa: PLR0904 @property def user_documents_dir(self) -> str: - """:return: documents directory tied to the user e.g. ``%USERPROFILE%\\Documents``""" + r""":returns: documents directory tied to the user e.g. ``%USERPROFILE%\Documents``""" return os.path.normpath(get_win_folder("CSIDL_PERSONAL")) @property def user_downloads_dir(self) -> str: - """:return: downloads directory tied to the user e.g. ``%USERPROFILE%\\Downloads``""" + r""":returns: downloads directory tied to the user e.g. ``%USERPROFILE%\Downloads``""" return os.path.normpath(get_win_folder("CSIDL_DOWNLOADS")) @property def user_pictures_dir(self) -> str: - """:return: pictures directory tied to the user e.g. ``%USERPROFILE%\\Pictures``""" + r""":returns: pictures directory tied to the user e.g. ``%USERPROFILE%\Pictures``""" return os.path.normpath(get_win_folder("CSIDL_MYPICTURES")) @property def user_videos_dir(self) -> str: - """:return: videos directory tied to the user e.g. ``%USERPROFILE%\\Videos``""" + r""":returns: videos directory tied to the user e.g. ``%USERPROFILE%\Videos``""" return os.path.normpath(get_win_folder("CSIDL_MYVIDEO")) @property def user_music_dir(self) -> str: - """:return: music directory tied to the user e.g. ``%USERPROFILE%\\Music``""" + r""":returns: music directory tied to the user e.g. ``%USERPROFILE%\Music``""" return os.path.normpath(get_win_folder("CSIDL_MYMUSIC")) @property def user_desktop_dir(self) -> str: - """:return: desktop directory tied to the user, e.g. ``%USERPROFILE%\\Desktop``""" + r""":returns: desktop directory tied to the user, e.g. ``%USERPROFILE%\Desktop``""" return os.path.normpath(get_win_folder("CSIDL_DESKTOPDIRECTORY")) @property def user_bin_dir(self) -> str: - """:return: bin directory tied to the user, e.g. ``%LOCALAPPDATA%\\Programs``""" + r""":returns: bin directory tied to the user, e.g. ``%LOCALAPPDATA%\Programs``""" return os.path.normpath(os.path.join(get_win_folder("CSIDL_LOCAL_APPDATA"), "Programs")) # noqa: PTH118 @property def site_bin_dir(self) -> str: - """:return: bin directory shared by users, e.g. ``C:\\ProgramData\\bin``""" + """:returns: bin directory shared by users, e.g. ``C:\\ProgramData\bin``""" return os.path.normpath(os.path.join(get_win_folder("CSIDL_COMMON_APPDATA"), "bin")) # noqa: PTH118 @property def user_applications_dir(self) -> str: - """:return: applications directory tied to the user, e.g. ``Start Menu\\Programs``""" + r""":returns: applications directory tied to the user, e.g. ``Start Menu\Programs``""" return os.path.normpath(get_win_folder("CSIDL_PROGRAMS")) @property def site_applications_dir(self) -> str: - """ - :return: applications directory shared by users, e.g. \ - ``C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs`` - """ + r""":returns: applications directory shared by users, e.g. ``C:\ProgramData\Microsoft\Windows\Start Menu\Programs``""" return os.path.normpath(get_win_folder("CSIDL_COMMON_PROGRAMS")) @property def user_runtime_dir(self) -> str: - """ - :return: runtime directory tied to the user, e.g. - ``%USERPROFILE%\\AppData\\Local\\Temp\\$appauthor\\$appname`` - """ + r""":returns: runtime directory tied to the user, e.g. ``%USERPROFILE%\AppData\Local\Temp\$appauthor\$appname``""" path = os.path.normpath(os.path.join(get_win_folder("CSIDL_LOCAL_APPDATA"), "Temp")) # noqa: PTH118 return self._append_parts(path) @property def site_runtime_dir(self) -> str: - """:return: runtime directory shared by users, same as `user_runtime_dir`""" + """:returns: runtime directory shared by users, same as `user_runtime_dir`""" return self.user_runtime_dir @@ -238,8 +224,7 @@ def get_win_folder_if_csidl_name_not_env_var(csidl_name: str) -> str | None: # def get_win_folder_from_registry(csidl_name: str) -> str: - """ - Get folder from the registry. + """Get folder from the registry. This is a fallback technique at best. I'm not sure if using the registry for these guarantees us the correct answer for all CSIDL_* names. @@ -292,8 +277,7 @@ _KNOWN_FOLDER_GUIDS: dict[str, str] = { def get_win_folder_via_ctypes(csidl_name: str) -> str: - """ - Get folder via :func:`SHGetKnownFolderPath`. + """Get folder via :func:`SHGetKnownFolderPath`. See https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath. @@ -369,8 +353,7 @@ _resolve_win_folder = _pick_get_win_folder() def get_win_folder(csidl_name: str) -> str: - """ - Get a Windows folder path, checking for ``WIN_PD_OVERRIDE_*`` environment variable overrides first. + """Get a Windows folder path, checking for ``WIN_PD_OVERRIDE_*`` environment variable overrides first. For example, ``CSIDL_LOCAL_APPDATA`` can be overridden by setting ``WIN_PD_OVERRIDE_LOCAL_APPDATA``. diff --git a/contrib/python/platformdirs/ya.make b/contrib/python/platformdirs/ya.make index 67c5b0e022a..73b2202a605 100644 --- a/contrib/python/platformdirs/ya.make +++ b/contrib/python/platformdirs/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(4.9.1) +VERSION(4.9.2) LICENSE(MIT) |
