diff options
| author | robot-piglet <[email protected]> | 2026-06-13 10:10:47 +0300 |
|---|---|---|
| committer | robot-piglet <[email protected]> | 2026-06-13 10:30:07 +0300 |
| commit | 27a12e8aa39050c21b94064ed09237f157f7f970 (patch) | |
| tree | 68f0b402376cbc4c1107e123bce13b1c5c150dcd /contrib/python | |
| parent | 55934b0bfff722c5d0af63cfadb627398b301604 (diff) | |
Intermediate changes
commit_hash:dd73f4bf5a8209ef115a4c853950b87c538ed6e8
Diffstat (limited to 'contrib/python')
| -rw-r--r-- | contrib/python/platformdirs/.dist-info/METADATA | 16 | ||||
| -rw-r--r-- | contrib/python/platformdirs/README.md | 14 | ||||
| -rw-r--r-- | contrib/python/platformdirs/platformdirs/__init__.py | 60 | ||||
| -rw-r--r-- | contrib/python/platformdirs/platformdirs/__main__.py | 5 | ||||
| -rw-r--r-- | contrib/python/platformdirs/platformdirs/_xdg.py | 28 | ||||
| -rw-r--r-- | contrib/python/platformdirs/platformdirs/android.py | 25 | ||||
| -rw-r--r-- | contrib/python/platformdirs/platformdirs/api.py | 50 | ||||
| -rw-r--r-- | contrib/python/platformdirs/platformdirs/macos.py | 30 | ||||
| -rw-r--r-- | contrib/python/platformdirs/platformdirs/unix.py | 25 | ||||
| -rw-r--r-- | contrib/python/platformdirs/platformdirs/version.py | 4 | ||||
| -rw-r--r-- | contrib/python/platformdirs/platformdirs/windows.py | 26 | ||||
| -rw-r--r-- | contrib/python/platformdirs/ya.make | 2 |
12 files changed, 279 insertions, 6 deletions
diff --git a/contrib/python/platformdirs/.dist-info/METADATA b/contrib/python/platformdirs/.dist-info/METADATA index f9ac753abd2..d77dee3062d 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.6 +Version: 4.10.0 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 @@ -75,14 +75,26 @@ user_config_path("MyApp", "MyCompany") # returns pathlib.Path ## Directory types +**Application directories** — scoped to your app name and version: + - **Data**: Persistent application data (`user_data_dir`, `site_data_dir`) - **Config**: Configuration files and settings (`user_config_dir`, `site_config_dir`) +- **Preference**: User preferences, distinct from config on macOS (`user_preference_dir`) - **Cache**: Cached data that can be regenerated (`user_cache_dir`, `site_cache_dir`) - **State**: Non-essential runtime state like window positions (`user_state_dir`, `site_state_dir`) - **Logs**: Log files (`user_log_dir`, `site_log_dir`) - **Runtime**: Runtime files like sockets and PIDs (`user_runtime_dir`, `site_runtime_dir`) -Each type has both `user_*` (per-user, writable) and `site_*` (system-wide, read-only for users) variants. +App dirs have both `user_*` (per-user, writable) and `site_*` (system-wide, read-only) variants where applicable. + +**User media directories** — standard user-facing folders, not scoped to app name: + +- **Documents** (`user_documents_dir`), **Downloads** (`user_downloads_dir`) +- **Pictures** (`user_pictures_dir`), **Videos** (`user_videos_dir`), **Music** (`user_music_dir`) +- **Desktop** (`user_desktop_dir`), **Projects** (`user_projects_dir`) +- **Public share** (`user_publicshare_dir`), **Templates** (`user_templates_dir`) +- **Fonts** (`user_fonts_dir`) — user-writable font installation directory +- **Executable** (`user_bin_dir`, `site_bin_dir`), **Applications** (`user_applications_dir`, `site_applications_dir`) ## Documentation diff --git a/contrib/python/platformdirs/README.md b/contrib/python/platformdirs/README.md index 7cd5d88e6e6..e2627bd7aa1 100644 --- a/contrib/python/platformdirs/README.md +++ b/contrib/python/platformdirs/README.md @@ -45,14 +45,26 @@ user_config_path("MyApp", "MyCompany") # returns pathlib.Path ## Directory types +**Application directories** — scoped to your app name and version: + - **Data**: Persistent application data (`user_data_dir`, `site_data_dir`) - **Config**: Configuration files and settings (`user_config_dir`, `site_config_dir`) +- **Preference**: User preferences, distinct from config on macOS (`user_preference_dir`) - **Cache**: Cached data that can be regenerated (`user_cache_dir`, `site_cache_dir`) - **State**: Non-essential runtime state like window positions (`user_state_dir`, `site_state_dir`) - **Logs**: Log files (`user_log_dir`, `site_log_dir`) - **Runtime**: Runtime files like sockets and PIDs (`user_runtime_dir`, `site_runtime_dir`) -Each type has both `user_*` (per-user, writable) and `site_*` (system-wide, read-only for users) variants. +App dirs have both `user_*` (per-user, writable) and `site_*` (system-wide, read-only) variants where applicable. + +**User media directories** — standard user-facing folders, not scoped to app name: + +- **Documents** (`user_documents_dir`), **Downloads** (`user_downloads_dir`) +- **Pictures** (`user_pictures_dir`), **Videos** (`user_videos_dir`), **Music** (`user_music_dir`) +- **Desktop** (`user_desktop_dir`), **Projects** (`user_projects_dir`) +- **Public share** (`user_publicshare_dir`), **Templates** (`user_templates_dir`) +- **Fonts** (`user_fonts_dir`) — user-writable font installation directory +- **Executable** (`user_bin_dir`, `site_bin_dir`), **Applications** (`user_applications_dir`, `site_applications_dir`) ## Documentation diff --git a/contrib/python/platformdirs/platformdirs/__init__.py b/contrib/python/platformdirs/platformdirs/__init__.py index 4ab450ea953..e9d3cb672b6 100644 --- a/contrib/python/platformdirs/platformdirs/__init__.py +++ b/contrib/python/platformdirs/platformdirs/__init__.py @@ -344,6 +344,31 @@ def user_desktop_dir() -> str: return PlatformDirs().user_desktop_dir +def user_projects_dir() -> str: + """:returns: projects directory tied to the user""" + return PlatformDirs().user_projects_dir + + +def user_publicshare_dir() -> str: + """:returns: public share directory tied to the user""" + return PlatformDirs().user_publicshare_dir + + +def user_templates_dir() -> str: + """:returns: templates directory tied to the user""" + return PlatformDirs().user_templates_dir + + +def user_fonts_dir() -> str: + """:returns: fonts directory tied to the user""" + return PlatformDirs().user_fonts_dir + + +def user_preference_dir() -> str: + """:returns: preference directory tied to the user""" + return PlatformDirs().user_preference_dir + + def user_bin_dir() -> str: """:returns: bin directory tied to the user""" return PlatformDirs().user_bin_dir @@ -720,6 +745,31 @@ def user_desktop_path() -> Path: return PlatformDirs().user_desktop_path +def user_projects_path() -> Path: + """:returns: projects path tied to the user""" + return PlatformDirs().user_projects_path + + +def user_publicshare_path() -> Path: + """:returns: public share path tied to the user""" + return PlatformDirs().user_publicshare_path + + +def user_templates_path() -> Path: + """:returns: templates path tied to the user""" + return PlatformDirs().user_templates_path + + +def user_fonts_path() -> Path: + """:returns: fonts path tied to the user""" + return PlatformDirs().user_fonts_path + + +def user_preference_path() -> Path: + """:returns: preference path tied to the user""" + return PlatformDirs().user_preference_path + + def user_bin_path() -> Path: """:returns: bin path tied to the user""" return PlatformDirs().user_bin_path @@ -842,16 +892,26 @@ __all__ = [ "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", ] diff --git a/contrib/python/platformdirs/platformdirs/__main__.py b/contrib/python/platformdirs/platformdirs/__main__.py index 2490ffbbe1b..7a52b7d407c 100644 --- a/contrib/python/platformdirs/platformdirs/__main__.py +++ b/contrib/python/platformdirs/platformdirs/__main__.py @@ -15,6 +15,11 @@ PROPS = ( "user_pictures_dir", "user_videos_dir", "user_music_dir", + "user_projects_dir", + "user_publicshare_dir", + "user_templates_dir", + "user_fonts_dir", + "user_preference_dir", "user_bin_dir", "site_bin_dir", "user_applications_dir", diff --git a/contrib/python/platformdirs/platformdirs/_xdg.py b/contrib/python/platformdirs/platformdirs/_xdg.py index 5ffbf93eb57..b2af284ae39 100644 --- a/contrib/python/platformdirs/platformdirs/_xdg.py +++ b/contrib/python/platformdirs/platformdirs/_xdg.py @@ -119,6 +119,34 @@ class XDGMixin(PlatformDirsABC): return super().user_desktop_dir @property + def user_projects_dir(self) -> str: + """:returns: projects directory tied to the user, from ``$XDG_PROJECTS_DIR`` if set, else platform default""" + if path := os.environ.get("XDG_PROJECTS_DIR", "").strip(): + return os.path.expanduser(path) # noqa: PTH111 # API returns str, not Path + return super().user_projects_dir + + @property + def user_publicshare_dir(self) -> str: + """:returns: public share directory tied to the user, from ``$XDG_PUBLICSHARE_DIR`` if set, else platform default""" + if path := os.environ.get("XDG_PUBLICSHARE_DIR", "").strip(): + return os.path.expanduser(path) # noqa: PTH111 # API returns str, not Path + return super().user_publicshare_dir + + @property + def user_templates_dir(self) -> str: + """:returns: templates directory tied to the user, from ``$XDG_TEMPLATES_DIR`` if set, else platform default""" + if path := os.environ.get("XDG_TEMPLATES_DIR", "").strip(): + return os.path.expanduser(path) # noqa: PTH111 # API returns str, not Path + return super().user_templates_dir + + @property + def user_fonts_dir(self) -> str: + """:returns: fonts directory tied to the user, from ``$XDG_DATA_HOME/fonts`` if set, else platform default""" + if path := os.environ.get("XDG_DATA_HOME", "").strip(): + return f"{os.path.expanduser(path)}/fonts" # noqa: PTH111 # API returns str, not Path + return super().user_fonts_dir + + @property def user_applications_dir(self) -> str: """: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(): diff --git a/contrib/python/platformdirs/platformdirs/android.py b/contrib/python/platformdirs/platformdirs/android.py index 8c798b95e31..885e8c6e154 100644 --- a/contrib/python/platformdirs/platformdirs/android.py +++ b/contrib/python/platformdirs/platformdirs/android.py @@ -108,6 +108,31 @@ class Android(PlatformDirsABC): # noqa: PLR0904 return "/storage/emulated/0/Desktop" @property + def user_projects_dir(self) -> str: + """:returns: projects directory tied to the user e.g. ``/storage/emulated/0/Projects``""" + return "/storage/emulated/0/Projects" + + @property + def user_publicshare_dir(self) -> str: + """:returns: public share directory tied to the user e.g. ``/storage/emulated/0/Public``""" + return "/storage/emulated/0/Public" + + @property + def user_templates_dir(self) -> str: + """:returns: templates directory tied to the user e.g. ``/storage/emulated/0/Templates``""" + return "/storage/emulated/0/Templates" + + @property + def user_fonts_dir(self) -> str: + """:returns: fonts directory tied to the user e.g. ``/storage/emulated/0/fonts``""" + return "/storage/emulated/0/fonts" + + @property + def user_preference_dir(self) -> str: + """:returns: preference directory tied to the user, same as ``user_config_dir``""" + return self.user_config_dir + + @property def user_bin_dir(self) -> str: """: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 diff --git a/contrib/python/platformdirs/platformdirs/api.py b/contrib/python/platformdirs/platformdirs/api.py index 1e3b9a97c65..91ef902858a 100644 --- a/contrib/python/platformdirs/platformdirs/api.py +++ b/contrib/python/platformdirs/platformdirs/api.py @@ -210,6 +210,31 @@ class PlatformDirsABC(ABC): # noqa: PLR0904 @property @abstractmethod + def user_projects_dir(self) -> str: + """:returns: projects directory tied to the user""" + + @property + @abstractmethod + def user_publicshare_dir(self) -> str: + """:returns: public share directory tied to the user""" + + @property + @abstractmethod + def user_templates_dir(self) -> str: + """:returns: templates directory tied to the user""" + + @property + @abstractmethod + def user_fonts_dir(self) -> str: + """:returns: fonts directory tied to the user""" + + @property + @abstractmethod + def user_preference_dir(self) -> str: + """:returns: preference directory tied to the user""" + + @property + @abstractmethod def user_bin_dir(self) -> str: """:returns: bin directory tied to the user""" @@ -323,6 +348,31 @@ class PlatformDirsABC(ABC): # noqa: PLR0904 return Path(self.user_desktop_dir) @property + def user_projects_path(self) -> Path: + """:returns: projects path tied to the user""" + return Path(self.user_projects_dir) + + @property + def user_publicshare_path(self) -> Path: + """:returns: public share path tied to the user""" + return Path(self.user_publicshare_dir) + + @property + def user_templates_path(self) -> Path: + """:returns: templates path tied to the user""" + return Path(self.user_templates_dir) + + @property + def user_fonts_path(self) -> Path: + """:returns: fonts path tied to the user""" + return Path(self.user_fonts_dir) + + @property + def user_preference_path(self) -> Path: + """:returns: preference path tied to the user""" + return Path(self.user_preference_dir) + + @property def user_bin_path(self) -> Path: """:returns: bin path tied to the user""" return Path(self.user_bin_dir) diff --git a/contrib/python/platformdirs/platformdirs/macos.py b/contrib/python/platformdirs/platformdirs/macos.py index 26447e396e3..9ebc2a0c549 100644 --- a/contrib/python/platformdirs/platformdirs/macos.py +++ b/contrib/python/platformdirs/platformdirs/macos.py @@ -50,6 +50,11 @@ class _MacOSDefaults(PlatformDirsABC): # noqa: PLR0904 return self._first_item_as_path_if_multipath(self.site_data_dir) @property + def site_config_path(self) -> Path: + """:returns: config 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_config_dir) + + @property def user_config_dir(self) -> str: """:returns: config directory tied to the user, same as `user_data_dir`""" return self._base_user_app_support_dir() @@ -130,6 +135,31 @@ class _MacOSDefaults(PlatformDirsABC): # noqa: PLR0904 return os.path.expanduser("~/Desktop") # noqa: PTH111 @property + def user_projects_dir(self) -> str: + """:returns: projects directory tied to the user, e.g. ``~/Projects``""" + return os.path.expanduser("~/Projects") # noqa: PTH111 + + @property + def user_publicshare_dir(self) -> str: + """:returns: public share directory tied to the user, e.g. ``~/Public``""" + return os.path.expanduser("~/Public") # noqa: PTH111 # API returns str, not Path + + @property + def user_templates_dir(self) -> str: + """:returns: templates directory tied to the user, e.g. ``~/Templates``""" + return os.path.expanduser("~/Templates") # noqa: PTH111 # API returns str, not Path + + @property + def user_fonts_dir(self) -> str: + """:returns: fonts directory tied to the user, e.g. ``~/Library/Fonts``""" + return os.path.expanduser("~/Library/Fonts") # noqa: PTH111 # API returns str, not Path + + @property + def user_preference_dir(self) -> str: + """:returns: preference directory tied to the user, e.g. ``~/Library/Preferences/AppName``""" + return self._append_app_name_and_version(os.path.expanduser("~/Library/Preferences")) # noqa: PTH111 # API returns str, not Path + + @property def user_bin_dir(self) -> str: """:returns: bin directory tied to the user, e.g. ``~/.local/bin``""" return os.path.expanduser("~/.local/bin") # noqa: PTH111 diff --git a/contrib/python/platformdirs/platformdirs/unix.py b/contrib/python/platformdirs/platformdirs/unix.py index 8ec5a6bc718..500d3a4be92 100644 --- a/contrib/python/platformdirs/platformdirs/unix.py +++ b/contrib/python/platformdirs/platformdirs/unix.py @@ -124,6 +124,31 @@ class _UnixDefaults(PlatformDirsABC): # noqa: PLR0904 return _get_user_media_dir("XDG_DESKTOP_DIR", "~/Desktop") @property + def user_projects_dir(self) -> str: + """:returns: projects directory tied to the user, e.g. ``~/Projects``""" + return _get_user_media_dir("XDG_PROJECTS_DIR", "~/Projects") + + @property + def user_publicshare_dir(self) -> str: + """:returns: public share directory tied to the user, e.g. ``~/Public``""" + return _get_user_media_dir("XDG_PUBLICSHARE_DIR", "~/Public") + + @property + def user_templates_dir(self) -> str: + """:returns: templates directory tied to the user, e.g. ``~/Templates``""" + return _get_user_media_dir("XDG_TEMPLATES_DIR", "~/Templates") + + @property + def user_fonts_dir(self) -> str: + """:returns: fonts directory tied to the user, e.g. ``~/.local/share/fonts``""" + return f"{os.path.expanduser('~/.local/share')}/fonts" # noqa: PTH111 # API returns str, not Path + + @property + def user_preference_dir(self) -> str: + """:returns: preference directory tied to the user, same as ``user_config_dir``""" + return self.user_config_dir + + @property def user_bin_dir(self) -> str: """:returns: bin directory tied to the user, e.g. ``~/.local/bin``""" return os.path.expanduser("~/.local/bin") # noqa: PTH111 diff --git a/contrib/python/platformdirs/platformdirs/version.py b/contrib/python/platformdirs/platformdirs/version.py index 99cae7946ef..a281775fdd8 100644 --- a/contrib/python/platformdirs/platformdirs/version.py +++ b/contrib/python/platformdirs/platformdirs/version.py @@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...] commit_id: str | None __commit_id__: str | None -__version__ = version = '4.9.6' -__version_tuple__ = version_tuple = (4, 9, 6) +__version__ = version = '4.10.0' +__version_tuple__ = version_tuple = (4, 10, 0) __commit_id__ = commit_id = None diff --git a/contrib/python/platformdirs/platformdirs/windows.py b/contrib/python/platformdirs/platformdirs/windows.py index 47403dea5ef..476ffe73605 100644 --- a/contrib/python/platformdirs/platformdirs/windows.py +++ b/contrib/python/platformdirs/platformdirs/windows.py @@ -4,6 +4,7 @@ from __future__ import annotations import os import sys +from pathlib import Path from typing import TYPE_CHECKING, Final from .api import PlatformDirsABC @@ -134,6 +135,31 @@ class Windows(PlatformDirsABC): # noqa: PLR0904 return os.path.normpath(get_win_folder("CSIDL_DESKTOPDIRECTORY")) @property + def user_projects_dir(self) -> str: + r""":returns: projects directory tied to the user, e.g. ``%USERPROFILE%\Projects``""" + return os.path.normpath(os.path.expanduser("~/Projects")) # noqa: PTH111 + + @property + def user_publicshare_dir(self) -> str: + r""":returns: public share directory e.g. ``C:\Users\Public``""" + return os.path.normpath(os.environ.get("PUBLIC", str(Path("~").expanduser().parent / "Public"))) + + @property + def user_templates_dir(self) -> str: + r""":returns: templates directory tied to the user e.g. ``%APPDATA%\Microsoft\Windows\Templates``""" + return os.path.normpath(str(Path(get_win_folder("CSIDL_APPDATA")) / "Microsoft" / "Windows" / "Templates")) + + @property + def user_fonts_dir(self) -> str: + r""":returns: fonts directory tied to the user e.g. ``%LOCALAPPDATA%\Microsoft\Windows\Fonts``""" + return os.path.normpath(str(Path(get_win_folder("CSIDL_LOCAL_APPDATA")) / "Microsoft" / "Windows" / "Fonts")) + + @property + def user_preference_dir(self) -> str: + r""":returns: preference directory tied to the user, same as ``user_config_dir``""" + return self.user_config_dir + + @property def user_bin_dir(self) -> str: 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 diff --git a/contrib/python/platformdirs/ya.make b/contrib/python/platformdirs/ya.make index 9155aa43b0a..b30eb7d7837 100644 --- a/contrib/python/platformdirs/ya.make +++ b/contrib/python/platformdirs/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(4.9.6) +VERSION(4.10.0) LICENSE(MIT) |
