@anaconda/desktop-bridge-payload-win32-arm64 0.1.21 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES +17 -17
- package/manifest.json +7 -7
- package/package.json +1 -1
- package/python/BUILD +1 -1
- package/python/DLLs/_asyncio.pyd +0 -0
- package/python/DLLs/_bz2.pyd +0 -0
- package/python/DLLs/_ctypes.pyd +0 -0
- package/python/DLLs/_ctypes_test.pyd +0 -0
- package/python/DLLs/_decimal.pyd +0 -0
- package/python/DLLs/_elementtree.pyd +0 -0
- package/python/DLLs/_hashlib.pyd +0 -0
- package/python/DLLs/_lzma.pyd +0 -0
- package/python/DLLs/_msi.pyd +0 -0
- package/python/DLLs/_multiprocessing.pyd +0 -0
- package/python/DLLs/_overlapped.pyd +0 -0
- package/python/DLLs/_queue.pyd +0 -0
- package/python/DLLs/_socket.pyd +0 -0
- package/python/DLLs/_sqlite3.pyd +0 -0
- package/python/DLLs/_ssl.pyd +0 -0
- package/python/DLLs/_testbuffer.pyd +0 -0
- package/python/DLLs/_testcapi.pyd +0 -0
- package/python/DLLs/_testconsole.pyd +0 -0
- package/python/DLLs/_testimportmultiple.pyd +0 -0
- package/python/DLLs/_testinternalcapi.pyd +0 -0
- package/python/DLLs/_testmultiphase.pyd +0 -0
- package/python/DLLs/_uuid.pyd +0 -0
- package/python/DLLs/_zoneinfo.pyd +0 -0
- package/python/DLLs/libcrypto-3-arm64.dll +0 -0
- package/python/DLLs/libffi-8.dll +0 -0
- package/python/DLLs/libssl-3-arm64.dll +0 -0
- package/python/DLLs/pyexpat.pyd +0 -0
- package/python/DLLs/select.pyd +0 -0
- package/python/DLLs/sqlite3.dll +0 -0
- package/python/DLLs/unicodedata.pyd +0 -0
- package/python/DLLs/winsound.pyd +0 -0
- package/python/Lib/site-packages/_ruamel_yaml.cp311-win_arm64.pyd +0 -0
- package/python/Lib/site-packages/anaconda_anon_usage-0.8.1.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/anaconda_auth-0.15.3.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/anaconda_cli_base-0.9.1.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/anaconda_desktop_bridge/__main__.py +8 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/__pycache__/__main__.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/__pycache__/errors.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/__pycache__/telemetry.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/conda/__init__.py +2 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/conda/__pycache__/__init__.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/conda/__pycache__/auth_handler.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/conda/__pycache__/auth_plugin.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/conda/__pycache__/lock.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/conda/__pycache__/repo_credentials.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/conda/auth_handler.py +219 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/conda/auth_plugin.py +50 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/conda/lock.py +26 -1
- package/python/Lib/site-packages/anaconda_desktop_bridge/conda/operations/__pycache__/channels.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/conda/operations/__pycache__/repodata.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/conda/operations/channels.py +196 -4
- package/python/Lib/site-packages/anaconda_desktop_bridge/conda/operations/repodata.py +8 -1
- package/python/Lib/site-packages/anaconda_desktop_bridge/conda/repo_credentials.py +224 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/conda/transactions/__pycache__/transaction.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/conda/transactions/transaction.py +23 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/errors.py +24 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/features/__pycache__/conda_tools.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/features/conda_tools.py +8 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/models/__pycache__/conda_tools.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/anaconda_desktop_bridge/models/conda_tools.py +46 -1
- package/python/Lib/site-packages/anaconda_desktop_bridge/telemetry.py +2 -20
- package/python/Lib/site-packages/anaconda_desktop_bridge-0.1.0.dist-info/METADATA +75 -5
- package/python/Lib/site-packages/anaconda_desktop_bridge-0.1.0.dist-info/RECORD +16 -13
- package/python/Lib/site-packages/anaconda_desktop_bridge-0.1.0.dist-info/uv_cache.json +1 -1
- package/python/Lib/site-packages/archspec-0.2.7.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/cffi-2.1.1.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/charset_normalizer-3.5.2.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/conda-26.1.1.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/conda_package_handling-2.6.0.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/distro-1.9.0.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/httpx-0.28.1.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/idna-3.20.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/jsonpatch-1.47.dist-info/RECORD +2 -2
- package/python/Lib/site-packages/keyring-25.7.0.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/markdown_it_py-4.3.0.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/menuinst/platforms/win_utils/winshortcut.cp311-win_arm64.pyd +0 -0
- package/python/Lib/site-packages/menuinst-2.5.1.dist-info/RECORD +2 -2
- package/python/Lib/site-packages/platformdirs/__init__.py +155 -128
- package/python/Lib/site-packages/platformdirs/__main__.py +10 -10
- package/python/Lib/site-packages/platformdirs/__pycache__/__init__.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/platformdirs/__pycache__/__main__.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/platformdirs/__pycache__/_android.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/platformdirs/__pycache__/_runtime.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/platformdirs/__pycache__/_xdg.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/platformdirs/__pycache__/android.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/platformdirs/__pycache__/api.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/platformdirs/__pycache__/ios.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/platformdirs/__pycache__/macos.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/platformdirs/__pycache__/pytest_plugin.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/platformdirs/__pycache__/testing.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/platformdirs/__pycache__/unix.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/platformdirs/__pycache__/version.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/platformdirs/__pycache__/windows.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/platformdirs/_android.py +67 -0
- package/python/Lib/site-packages/platformdirs/_runtime.py +65 -0
- package/python/Lib/site-packages/platformdirs/_xdg.py +50 -47
- package/python/Lib/site-packages/platformdirs/android.py +64 -112
- package/python/Lib/site-packages/platformdirs/api.py +384 -293
- package/python/Lib/site-packages/platformdirs/ios.py +40 -40
- package/python/Lib/site-packages/platformdirs/macos.py +95 -72
- package/python/Lib/site-packages/platformdirs/pytest_plugin.py +5 -4
- package/python/Lib/site-packages/platformdirs/testing.py +23 -21
- package/python/Lib/site-packages/platformdirs/unix.py +158 -169
- package/python/Lib/site-packages/platformdirs/version.py +2 -2
- package/python/Lib/site-packages/platformdirs/windows.py +135 -121
- package/python/Lib/site-packages/{platformdirs-4.14.5.dist-info → platformdirs-4.14.7.dist-info}/METADATA +1 -1
- package/python/Lib/site-packages/platformdirs-4.14.7.dist-info/RECORD +23 -0
- package/python/Lib/site-packages/{pydantic_settings-2.16.2.dist-info → platformdirs-4.14.7.dist-info}/WHEEL +1 -1
- package/python/Lib/site-packages/platformdirs-4.14.7.dist-info/sboms/platformdirs.cdx.json +14820 -0
- package/python/Lib/site-packages/pycosat-0.6.6.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/pycosat.cp311-win_arm64.pyd +0 -0
- package/python/Lib/site-packages/pydantic_settings/__pycache__/version.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/pydantic_settings/sources/providers/__pycache__/cli.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/pydantic_settings/sources/providers/__pycache__/nested_secrets.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/pydantic_settings/sources/providers/__pycache__/secrets.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/pydantic_settings/sources/providers/cli.py +13 -16
- package/python/Lib/site-packages/pydantic_settings/sources/providers/nested_secrets.py +32 -18
- package/python/Lib/site-packages/pydantic_settings/sources/providers/secrets.py +20 -1
- package/python/Lib/site-packages/pydantic_settings/version.py +1 -1
- package/python/Lib/site-packages/{pydantic_settings-2.16.2.dist-info → pydantic_settings-2.16.3.dist-info}/METADATA +1 -1
- package/python/Lib/site-packages/{pydantic_settings-2.16.2.dist-info → pydantic_settings-2.16.3.dist-info}/RECORD +10 -10
- package/python/Lib/site-packages/pygments-2.21.0.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/python_dotenv-1.2.4.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/ruamel_yaml_clib-0.2.15.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/semver/__about__.py +1 -1
- package/python/Lib/site-packages/semver/__pycache__/__about__.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/semver/__pycache__/version.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/semver/version.py +16 -5
- package/python/Lib/site-packages/{semver-3.1.1.dist-info → semver-3.1.2.dist-info}/METADATA +1 -1
- package/python/Lib/site-packages/semver-3.1.2.dist-info/RECORD +17 -0
- package/python/Lib/site-packages/sentry_sdk/__pycache__/_types.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/__pycache__/client.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/__pycache__/consts.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/__pycache__/traces.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/__pycache__/utils.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/_types.py +27 -3
- package/python/Lib/site-packages/sentry_sdk/client.py +1 -1
- package/python/Lib/site-packages/sentry_sdk/consts.py +7 -1
- package/python/Lib/site-packages/sentry_sdk/crons/__pycache__/decorator.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/crons/__pycache__/utils.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/crons/decorator.py +2 -0
- package/python/Lib/site-packages/sentry_sdk/crons/utils.py +26 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/__pycache__/arq.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/__pycache__/gql.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/__pycache__/huggingface_hub.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/__pycache__/starlette.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/__pycache__/trytond.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/arq.py +9 -16
- package/python/Lib/site-packages/sentry_sdk/integrations/boto3/__init__.py +2 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/boto3/__pycache__/__init__.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/boto3/__pycache__/_client.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/boto3/__pycache__/_instrumentation.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/boto3/_client.py +13 -15
- package/python/Lib/site-packages/sentry_sdk/integrations/boto3/_instrumentation.py +11 -13
- package/python/Lib/site-packages/sentry_sdk/integrations/boto3/_services/__pycache__/base.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/boto3/_services/__pycache__/bedrock.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/boto3/_services/base.py +16 -7
- package/python/Lib/site-packages/sentry_sdk/integrations/boto3/_services/bedrock.py +771 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/celery/__init__.py +3 -2
- package/python/Lib/site-packages/sentry_sdk/integrations/celery/__pycache__/__init__.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/django/__init__.py +1 -1
- package/python/Lib/site-packages/sentry_sdk/integrations/django/__pycache__/__init__.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/django/__pycache__/signals_handlers.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/django/signals_handlers.py +1 -1
- package/python/Lib/site-packages/sentry_sdk/integrations/gql.py +28 -3
- package/python/Lib/site-packages/sentry_sdk/integrations/huggingface_hub.py +1 -1
- package/python/Lib/site-packages/sentry_sdk/integrations/openai_agents/__init__.py +1 -1
- package/python/Lib/site-packages/sentry_sdk/integrations/openai_agents/__pycache__/__init__.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/starlette.py +2 -2
- package/python/Lib/site-packages/sentry_sdk/integrations/trytond.py +1 -1
- package/python/Lib/site-packages/sentry_sdk/profiler/__pycache__/continuous_profiler.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/profiler/__pycache__/transaction_profiler.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/profiler/continuous_profiler.py +0 -3
- package/python/Lib/site-packages/sentry_sdk/profiler/transaction_profiler.py +1 -1
- package/python/Lib/site-packages/sentry_sdk/traces.py +1 -1
- package/python/Lib/site-packages/sentry_sdk/utils.py +17 -4
- package/python/Lib/site-packages/{sentry_sdk-2.74.0.dist-info → sentry_sdk-2.75.0.dist-info}/METADATA +1 -1
- package/python/Lib/site-packages/{sentry_sdk-2.74.0.dist-info → sentry_sdk-2.75.0.dist-info}/RECORD +31 -31
- package/python/Lib/site-packages/tqdm-4.70.1.dist-info/RECORD +1 -1
- package/python/Lib/site-packages/typer-0.29.1.dist-info/RECORD +1 -1
- package/python/Lib/venv/scripts/nt/python.exe +0 -0
- package/python/Lib/venv/scripts/nt/pythonw.exe +0 -0
- package/python/Scripts/conda.exe +0 -0
- package/python/libs/_asyncio.lib +0 -0
- package/python/libs/_bz2.lib +0 -0
- package/python/libs/_ctypes.lib +0 -0
- package/python/libs/_ctypes_test.lib +0 -0
- package/python/libs/_decimal.lib +0 -0
- package/python/libs/_elementtree.lib +0 -0
- package/python/libs/_hashlib.lib +0 -0
- package/python/libs/_lzma.lib +0 -0
- package/python/libs/_msi.lib +0 -0
- package/python/libs/_multiprocessing.lib +0 -0
- package/python/libs/_overlapped.lib +0 -0
- package/python/libs/_queue.lib +0 -0
- package/python/libs/_socket.lib +0 -0
- package/python/libs/_sqlite3.lib +0 -0
- package/python/libs/_ssl.lib +0 -0
- package/python/libs/_testbuffer.lib +0 -0
- package/python/libs/_testcapi.lib +0 -0
- package/python/libs/_testconsole.lib +0 -0
- package/python/libs/_testimportmultiple.lib +0 -0
- package/python/libs/_testinternalcapi.lib +0 -0
- package/python/libs/_testmultiphase.lib +0 -0
- package/python/libs/_tkinter.lib +0 -0
- package/python/libs/_uuid.lib +0 -0
- package/python/libs/_zoneinfo.lib +0 -0
- package/python/libs/pyexpat.lib +0 -0
- package/python/libs/python3.lib +0 -0
- package/python/libs/python311.lib +0 -0
- package/python/libs/select.lib +0 -0
- package/python/libs/sqlite3.lib +0 -0
- package/python/libs/unicodedata.lib +0 -0
- package/python/libs/winsound.lib +0 -0
- package/python/python.exe +0 -0
- package/python/python3.dll +0 -0
- package/python/python311.dll +0 -0
- package/python/pythonw.exe +0 -0
- package/python/Lib/site-packages/platformdirs-4.14.5.dist-info/RECORD +0 -20
- package/python/Lib/site-packages/semver-3.1.1.dist-info/RECORD +0 -17
- package/python/Lib/site-packages/sentry_sdk/integrations/boto3/_services/__pycache__/registry.cpython-311.pyc +0 -0
- package/python/Lib/site-packages/sentry_sdk/integrations/boto3/_services/registry.py +0 -22
- /package/python/Lib/site-packages/{platformdirs-4.14.5.dist-info → platformdirs-4.14.7.dist-info}/INSTALLER +0 -0
- /package/python/Lib/site-packages/{platformdirs-4.14.5.dist-info → platformdirs-4.14.7.dist-info}/REQUESTED +0 -0
- /package/python/Lib/site-packages/{platformdirs-4.14.5.dist-info → platformdirs-4.14.7.dist-info}/entry_points.txt +0 -0
- /package/python/Lib/site-packages/{platformdirs-4.14.5.dist-info → platformdirs-4.14.7.dist-info}/licenses/LICENSE +0 -0
- /package/python/Lib/site-packages/{pydantic_settings-2.16.2.dist-info → pydantic_settings-2.16.3.dist-info}/INSTALLER +0 -0
- /package/python/Lib/site-packages/{pydantic_settings-2.16.2.dist-info → pydantic_settings-2.16.3.dist-info}/REQUESTED +0 -0
- /package/python/Lib/site-packages/{platformdirs-4.14.5.dist-info → pydantic_settings-2.16.3.dist-info}/WHEEL +0 -0
- /package/python/Lib/site-packages/{pydantic_settings-2.16.2.dist-info → pydantic_settings-2.16.3.dist-info}/licenses/LICENSE +0 -0
- /package/python/Lib/site-packages/{semver-3.1.1.dist-info → semver-3.1.2.dist-info}/INSTALLER +0 -0
- /package/python/Lib/site-packages/{semver-3.1.1.dist-info → semver-3.1.2.dist-info}/REQUESTED +0 -0
- /package/python/Lib/site-packages/{semver-3.1.1.dist-info → semver-3.1.2.dist-info}/WHEEL +0 -0
- /package/python/Lib/site-packages/{semver-3.1.1.dist-info → semver-3.1.2.dist-info}/entry_points.txt +0 -0
- /package/python/Lib/site-packages/{semver-3.1.1.dist-info → semver-3.1.2.dist-info}/licenses/LICENSE.txt +0 -0
- /package/python/Lib/site-packages/{semver-3.1.1.dist-info → semver-3.1.2.dist-info}/top_level.txt +0 -0
- /package/python/Lib/site-packages/{sentry_sdk-2.74.0.dist-info → sentry_sdk-2.75.0.dist-info}/INSTALLER +0 -0
- /package/python/Lib/site-packages/{sentry_sdk-2.74.0.dist-info → sentry_sdk-2.75.0.dist-info}/REQUESTED +0 -0
- /package/python/Lib/site-packages/{sentry_sdk-2.74.0.dist-info → sentry_sdk-2.75.0.dist-info}/WHEEL +0 -0
- /package/python/Lib/site-packages/{sentry_sdk-2.74.0.dist-info → sentry_sdk-2.75.0.dist-info}/entry_points.txt +0 -0
- /package/python/Lib/site-packages/{sentry_sdk-2.74.0.dist-info → sentry_sdk-2.75.0.dist-info}/licenses/LICENSE +0 -0
- /package/python/Lib/site-packages/{sentry_sdk-2.74.0.dist-info → sentry_sdk-2.75.0.dist-info}/top_level.txt +0 -0
|
@@ -6,15 +6,16 @@ import os
|
|
|
6
6
|
from abc import ABC, abstractmethod
|
|
7
7
|
from copy import copy
|
|
8
8
|
from pathlib import Path
|
|
9
|
-
from typing import TYPE_CHECKING
|
|
10
9
|
|
|
10
|
+
TYPE_CHECKING = False #: :data:`typing.TYPE_CHECKING` without importing :mod:`typing` at runtime
|
|
11
11
|
if TYPE_CHECKING:
|
|
12
12
|
from collections.abc import Callable, Iterable, Iterator
|
|
13
13
|
from typing import Literal
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
class PlatformDirsABC(ABC): # ruff:ignore[too-many-public-methods]
|
|
17
|
-
"""Abstract base class defining all platform directory properties, their :class:`~pathlib.Path` variants, and
|
|
16
|
+
class PlatformDirsABC(ABC): # ruff:ignore[too-many-public-methods] # full directory API # simplint: ignore[missing-from-all] # preserve star imports
|
|
17
|
+
"""Abstract base class defining all platform directory properties, their :class:`~pathlib.Path` variants, and
|
|
18
|
+
iterators.
|
|
18
19
|
|
|
19
20
|
Platform-specific subclasses (e.g. :class:`~platformdirs.windows.Windows`, :class:`~platformdirs.macos.MacOS`,
|
|
20
21
|
:class:`~platformdirs.unix.Unix`) implement the abstract properties to return the appropriate paths for each
|
|
@@ -22,16 +23,16 @@ class PlatformDirsABC(ABC): # ruff:ignore[too-many-public-methods]
|
|
|
22
23
|
|
|
23
24
|
"""
|
|
24
25
|
|
|
25
|
-
def __init__( # ruff:ignore[too-many-arguments, too-many-positional-arguments]
|
|
26
|
+
def __init__( # ruff:ignore[too-many-arguments, too-many-positional-arguments] # preserve positional API
|
|
26
27
|
self,
|
|
27
28
|
appname: str | None = None,
|
|
28
29
|
appauthor: str | Literal[False] | None = None,
|
|
29
30
|
version: str | None = None,
|
|
30
|
-
roaming: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument]
|
|
31
|
-
multipath: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument]
|
|
32
|
-
opinion: bool = True, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument]
|
|
33
|
-
ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument]
|
|
34
|
-
use_site_for_root: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument]
|
|
31
|
+
roaming: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] # preserve positional API
|
|
32
|
+
multipath: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] # preserve positional API
|
|
33
|
+
opinion: bool = True, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] # preserve positional API
|
|
34
|
+
ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] # preserve positional API
|
|
35
|
+
use_site_for_root: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] # preserve positional API
|
|
35
36
|
) -> None:
|
|
36
37
|
"""Create a new platform directory.
|
|
37
38
|
|
|
@@ -132,18 +133,26 @@ class PlatformDirsABC(ABC): # ruff:ignore[too-many-public-methods]
|
|
|
132
133
|
_ensure_inside_base("version", value)
|
|
133
134
|
self._version = value
|
|
134
135
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return
|
|
136
|
+
@property
|
|
137
|
+
def user_data_path(self) -> Path:
|
|
138
|
+
"""Data path tied to the user."""
|
|
139
|
+
return Path(self.user_data_dir)
|
|
139
140
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
141
|
+
@property
|
|
142
|
+
@abstractmethod
|
|
143
|
+
def user_data_dir(self) -> str:
|
|
144
|
+
"""Data directory tied to the user."""
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def site_data_path(self) -> Path:
|
|
148
|
+
"""Data path shared by users. Only return the first item, even if ``multipath`` is set to ``True``."""
|
|
149
|
+
return self._first_site_dir_as_path(self._site_data_dirs)
|
|
150
|
+
|
|
151
|
+
def _first_site_dir_as_path(self, dirs: list[str]) -> Path:
|
|
152
|
+
# A *_path property always returns the first entry, regardless of multipath, so only that entry is created.
|
|
153
|
+
path = dirs[0]
|
|
154
|
+
self._optionally_create_directory(path, private=False)
|
|
155
|
+
return Path(path)
|
|
147
156
|
|
|
148
157
|
def _optionally_create_directory(self, path: str, *, private: bool) -> None:
|
|
149
158
|
if not self.ensure_exists:
|
|
@@ -154,41 +163,9 @@ class PlatformDirsABC(ABC): # ruff:ignore[too-many-public-methods]
|
|
|
154
163
|
else:
|
|
155
164
|
Path(path).mkdir(parents=True, exist_ok=True)
|
|
156
165
|
|
|
157
|
-
def _optionally_create_media_directory(self, path: str) -> None:
|
|
158
|
-
# Only called for a media directory the user configured. Media directories are often symlinks to removable or
|
|
159
|
-
# network storage, so a dangling link is returned as-is, like before ensure_exists covered them.
|
|
160
|
-
try:
|
|
161
|
-
self._optionally_create_directory(path, private=False)
|
|
162
|
-
except FileExistsError:
|
|
163
|
-
if not (directory := Path(path)).is_symlink() or directory.exists():
|
|
164
|
-
raise
|
|
165
|
-
|
|
166
|
-
def _select_site_dirs(self, dirs: list[str]) -> str:
|
|
167
|
-
# Site lists are built without touching the disk, so ensure_exists only creates what the caller gets back.
|
|
168
|
-
selected = dirs if self.multipath else dirs[:1]
|
|
169
|
-
if self.multipath and any(os.pathsep in path for path in selected):
|
|
170
|
-
# Callers split the joined string on os.pathsep, so a separator inside one entry reads as two directories.
|
|
171
|
-
msg = f"multipath cannot join site directories that contain {os.pathsep!r}, got {selected!r}"
|
|
172
|
-
raise ValueError(msg)
|
|
173
|
-
for path in selected:
|
|
174
|
-
self._optionally_create_directory(path, private=False)
|
|
175
|
-
return os.pathsep.join(selected)
|
|
176
|
-
|
|
177
|
-
def _create_as_yielded(self, dirs: Iterable[str]) -> Iterator[str]:
|
|
178
|
-
for path in dirs:
|
|
179
|
-
self._optionally_create_directory(path, private=False)
|
|
180
|
-
yield path
|
|
181
|
-
|
|
182
|
-
def _first_site_dir_as_path(self, dirs: list[str]) -> Path:
|
|
183
|
-
# A *_path property always returns the first entry, regardless of multipath, so only that entry is created.
|
|
184
|
-
path = dirs[0]
|
|
185
|
-
self._optionally_create_directory(path, private=False)
|
|
186
|
-
return Path(path)
|
|
187
|
-
|
|
188
166
|
@property
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
"""Data directory tied to the user."""
|
|
167
|
+
def _site_data_dirs(self) -> list[str]:
|
|
168
|
+
return [self.site_data_dir]
|
|
192
169
|
|
|
193
170
|
@property
|
|
194
171
|
@abstractmethod
|
|
@@ -196,283 +173,307 @@ class PlatformDirsABC(ABC): # ruff:ignore[too-many-public-methods]
|
|
|
196
173
|
"""Data directory shared by users."""
|
|
197
174
|
|
|
198
175
|
@property
|
|
199
|
-
def
|
|
200
|
-
|
|
176
|
+
def user_config_path(self) -> Path:
|
|
177
|
+
"""Config path tied to the user."""
|
|
178
|
+
return Path(self.user_config_dir)
|
|
201
179
|
|
|
202
180
|
@property
|
|
203
181
|
@abstractmethod
|
|
204
182
|
def user_config_dir(self) -> str:
|
|
205
183
|
"""Config directory tied to the user."""
|
|
206
184
|
|
|
185
|
+
@property
|
|
186
|
+
def site_config_path(self) -> Path:
|
|
187
|
+
"""Config path shared by users. Only return the first item, even if ``multipath`` is set to ``True``."""
|
|
188
|
+
return self._first_site_dir_as_path(self._site_config_dirs)
|
|
189
|
+
|
|
190
|
+
@property
|
|
191
|
+
def _site_config_dirs(self) -> list[str]:
|
|
192
|
+
return [self.site_config_dir]
|
|
193
|
+
|
|
207
194
|
@property
|
|
208
195
|
@abstractmethod
|
|
209
196
|
def site_config_dir(self) -> str:
|
|
210
197
|
"""Config directory shared by users."""
|
|
211
198
|
|
|
212
199
|
@property
|
|
213
|
-
def
|
|
214
|
-
|
|
200
|
+
def user_cache_path(self) -> Path:
|
|
201
|
+
"""Cache path tied to the user."""
|
|
202
|
+
return Path(self.user_cache_dir)
|
|
215
203
|
|
|
216
204
|
@property
|
|
217
205
|
@abstractmethod
|
|
218
206
|
def user_cache_dir(self) -> str:
|
|
219
207
|
"""Cache directory tied to the user."""
|
|
220
208
|
|
|
209
|
+
@property
|
|
210
|
+
def site_cache_path(self) -> Path:
|
|
211
|
+
"""Cache path shared by users. Only return the first item, even if ``multipath`` is set to ``True``."""
|
|
212
|
+
return self._first_site_dir_as_path(self._site_cache_dirs)
|
|
213
|
+
|
|
214
|
+
@property
|
|
215
|
+
def _site_cache_dirs(self) -> list[str]:
|
|
216
|
+
return [self.site_cache_dir]
|
|
217
|
+
|
|
221
218
|
@property
|
|
222
219
|
@abstractmethod
|
|
223
220
|
def site_cache_dir(self) -> str:
|
|
224
221
|
"""Cache directory shared by users."""
|
|
225
222
|
|
|
226
223
|
@property
|
|
227
|
-
def
|
|
228
|
-
|
|
224
|
+
def user_state_path(self) -> Path:
|
|
225
|
+
"""State path tied to the user."""
|
|
226
|
+
return Path(self.user_state_dir)
|
|
229
227
|
|
|
230
228
|
@property
|
|
231
229
|
@abstractmethod
|
|
232
230
|
def user_state_dir(self) -> str:
|
|
233
231
|
"""State directory tied to the user."""
|
|
234
232
|
|
|
233
|
+
@property
|
|
234
|
+
def site_state_path(self) -> Path:
|
|
235
|
+
"""State path shared by users."""
|
|
236
|
+
return Path(self.site_state_dir)
|
|
237
|
+
|
|
235
238
|
@property
|
|
236
239
|
@abstractmethod
|
|
237
240
|
def site_state_dir(self) -> str:
|
|
238
241
|
"""State directory shared by users."""
|
|
239
242
|
|
|
243
|
+
@property
|
|
244
|
+
def user_log_path(self) -> Path:
|
|
245
|
+
"""Log path tied to the user."""
|
|
246
|
+
return Path(self.user_log_dir)
|
|
247
|
+
|
|
240
248
|
@property
|
|
241
249
|
@abstractmethod
|
|
242
250
|
def user_log_dir(self) -> str:
|
|
243
251
|
"""Log directory tied to the user."""
|
|
244
252
|
|
|
253
|
+
@property
|
|
254
|
+
def site_log_path(self) -> Path:
|
|
255
|
+
"""Log path shared by users."""
|
|
256
|
+
return Path(self.site_log_dir)
|
|
257
|
+
|
|
245
258
|
@property
|
|
246
259
|
@abstractmethod
|
|
247
260
|
def site_log_dir(self) -> str:
|
|
248
261
|
"""Log directory shared by users."""
|
|
249
262
|
|
|
263
|
+
@property
|
|
264
|
+
def user_documents_path(self) -> Path:
|
|
265
|
+
"""Documents path tied to the user."""
|
|
266
|
+
return Path(self.user_documents_dir)
|
|
267
|
+
|
|
250
268
|
@property
|
|
251
269
|
@abstractmethod
|
|
252
270
|
def user_documents_dir(self) -> str:
|
|
253
271
|
"""Documents directory tied to the user."""
|
|
254
272
|
|
|
273
|
+
@property
|
|
274
|
+
def user_downloads_path(self) -> Path:
|
|
275
|
+
"""Downloads path tied to the user."""
|
|
276
|
+
return Path(self.user_downloads_dir)
|
|
277
|
+
|
|
255
278
|
@property
|
|
256
279
|
@abstractmethod
|
|
257
280
|
def user_downloads_dir(self) -> str:
|
|
258
281
|
"""Downloads directory tied to the user."""
|
|
259
282
|
|
|
283
|
+
@property
|
|
284
|
+
def user_pictures_path(self) -> Path:
|
|
285
|
+
"""Pictures path tied to the user."""
|
|
286
|
+
return Path(self.user_pictures_dir)
|
|
287
|
+
|
|
260
288
|
@property
|
|
261
289
|
@abstractmethod
|
|
262
290
|
def user_pictures_dir(self) -> str:
|
|
263
291
|
"""Pictures directory tied to the user."""
|
|
264
292
|
|
|
293
|
+
@property
|
|
294
|
+
def user_videos_path(self) -> Path:
|
|
295
|
+
"""Videos path tied to the user."""
|
|
296
|
+
return Path(self.user_videos_dir)
|
|
297
|
+
|
|
265
298
|
@property
|
|
266
299
|
@abstractmethod
|
|
267
300
|
def user_videos_dir(self) -> str:
|
|
268
301
|
"""Videos directory tied to the user."""
|
|
269
302
|
|
|
303
|
+
@property
|
|
304
|
+
def user_music_path(self) -> Path:
|
|
305
|
+
"""Music path tied to the user."""
|
|
306
|
+
return Path(self.user_music_dir)
|
|
307
|
+
|
|
270
308
|
@property
|
|
271
309
|
@abstractmethod
|
|
272
310
|
def user_music_dir(self) -> str:
|
|
273
311
|
"""Music directory tied to the user."""
|
|
274
312
|
|
|
313
|
+
@property
|
|
314
|
+
def user_desktop_path(self) -> Path:
|
|
315
|
+
"""Desktop path tied to the user."""
|
|
316
|
+
return Path(self.user_desktop_dir)
|
|
317
|
+
|
|
275
318
|
@property
|
|
276
319
|
@abstractmethod
|
|
277
320
|
def user_desktop_dir(self) -> str:
|
|
278
321
|
"""Desktop directory tied to the user."""
|
|
279
322
|
|
|
323
|
+
@property
|
|
324
|
+
def user_projects_path(self) -> Path:
|
|
325
|
+
"""Projects path tied to the user."""
|
|
326
|
+
return Path(self.user_projects_dir)
|
|
327
|
+
|
|
280
328
|
@property
|
|
281
329
|
@abstractmethod
|
|
282
330
|
def user_projects_dir(self) -> str:
|
|
283
331
|
"""Projects directory tied to the user."""
|
|
284
332
|
|
|
333
|
+
@property
|
|
334
|
+
def user_publicshare_path(self) -> Path:
|
|
335
|
+
"""Public share path tied to the user."""
|
|
336
|
+
return Path(self.user_publicshare_dir)
|
|
337
|
+
|
|
285
338
|
@property
|
|
286
339
|
@abstractmethod
|
|
287
340
|
def user_publicshare_dir(self) -> str:
|
|
288
341
|
"""Public share directory tied to the user."""
|
|
289
342
|
|
|
343
|
+
@property
|
|
344
|
+
def user_templates_path(self) -> Path:
|
|
345
|
+
"""Templates path tied to the user."""
|
|
346
|
+
return Path(self.user_templates_dir)
|
|
347
|
+
|
|
290
348
|
@property
|
|
291
349
|
@abstractmethod
|
|
292
350
|
def user_templates_dir(self) -> str:
|
|
293
351
|
"""Templates directory tied to the user."""
|
|
294
352
|
|
|
353
|
+
@property
|
|
354
|
+
def user_fonts_path(self) -> Path:
|
|
355
|
+
"""Fonts path tied to the user."""
|
|
356
|
+
return Path(self.user_fonts_dir)
|
|
357
|
+
|
|
295
358
|
@property
|
|
296
359
|
@abstractmethod
|
|
297
360
|
def user_fonts_dir(self) -> str:
|
|
298
361
|
"""Fonts directory tied to the user."""
|
|
299
362
|
|
|
363
|
+
@property
|
|
364
|
+
def user_preference_path(self) -> Path:
|
|
365
|
+
"""Preference path tied to the user."""
|
|
366
|
+
return Path(self.user_preference_dir)
|
|
367
|
+
|
|
300
368
|
@property
|
|
301
369
|
@abstractmethod
|
|
302
370
|
def user_preference_dir(self) -> str:
|
|
303
371
|
"""Preference directory tied to the user."""
|
|
304
372
|
|
|
305
373
|
@property
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
374
|
+
def user_bin_path(self) -> Path:
|
|
375
|
+
"""Bin path tied to the user."""
|
|
376
|
+
return Path(self.user_bin_dir)
|
|
309
377
|
|
|
310
378
|
@property
|
|
311
379
|
@abstractmethod
|
|
312
|
-
def
|
|
313
|
-
"""Bin directory
|
|
380
|
+
def user_bin_dir(self) -> str:
|
|
381
|
+
"""Bin directory tied to the user."""
|
|
314
382
|
|
|
315
383
|
@property
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
384
|
+
def site_bin_path(self) -> Path:
|
|
385
|
+
"""Bin path shared by users."""
|
|
386
|
+
return Path(self.site_bin_dir)
|
|
319
387
|
|
|
320
388
|
@property
|
|
321
389
|
@abstractmethod
|
|
322
|
-
def
|
|
323
|
-
"""
|
|
324
|
-
|
|
325
|
-
@property
|
|
326
|
-
def _site_applications_dirs(self) -> list[str]:
|
|
327
|
-
return [self.site_applications_dir]
|
|
390
|
+
def site_bin_dir(self) -> str:
|
|
391
|
+
"""Bin directory shared by users."""
|
|
328
392
|
|
|
329
393
|
@property
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
394
|
+
def user_applications_path(self) -> Path:
|
|
395
|
+
"""Applications path tied to the user."""
|
|
396
|
+
return Path(self.user_applications_dir)
|
|
333
397
|
|
|
334
398
|
@property
|
|
335
399
|
@abstractmethod
|
|
336
|
-
def
|
|
337
|
-
"""
|
|
338
|
-
|
|
339
|
-
@property
|
|
340
|
-
def user_data_path(self) -> Path:
|
|
341
|
-
"""Data path tied to the user."""
|
|
342
|
-
return Path(self.user_data_dir)
|
|
343
|
-
|
|
344
|
-
@property
|
|
345
|
-
def site_data_path(self) -> Path:
|
|
346
|
-
"""Data path shared by users. Only return the first item, even if ``multipath`` is set to ``True``."""
|
|
347
|
-
return self._first_site_dir_as_path(self._site_data_dirs)
|
|
348
|
-
|
|
349
|
-
@property
|
|
350
|
-
def user_config_path(self) -> Path:
|
|
351
|
-
"""Config path tied to the user."""
|
|
352
|
-
return Path(self.user_config_dir)
|
|
353
|
-
|
|
354
|
-
@property
|
|
355
|
-
def site_config_path(self) -> Path:
|
|
356
|
-
"""Config path shared by users. Only return the first item, even if ``multipath`` is set to ``True``."""
|
|
357
|
-
return self._first_site_dir_as_path(self._site_config_dirs)
|
|
358
|
-
|
|
359
|
-
@property
|
|
360
|
-
def user_cache_path(self) -> Path:
|
|
361
|
-
"""Cache path tied to the user."""
|
|
362
|
-
return Path(self.user_cache_dir)
|
|
363
|
-
|
|
364
|
-
@property
|
|
365
|
-
def site_cache_path(self) -> Path:
|
|
366
|
-
"""Cache path shared by users. Only return the first item, even if ``multipath`` is set to ``True``."""
|
|
367
|
-
return self._first_site_dir_as_path(self._site_cache_dirs)
|
|
368
|
-
|
|
369
|
-
@property
|
|
370
|
-
def user_state_path(self) -> Path:
|
|
371
|
-
"""State path tied to the user."""
|
|
372
|
-
return Path(self.user_state_dir)
|
|
373
|
-
|
|
374
|
-
@property
|
|
375
|
-
def site_state_path(self) -> Path:
|
|
376
|
-
"""State path shared by users."""
|
|
377
|
-
return Path(self.site_state_dir)
|
|
378
|
-
|
|
379
|
-
@property
|
|
380
|
-
def user_log_path(self) -> Path:
|
|
381
|
-
"""Log path tied to the user."""
|
|
382
|
-
return Path(self.user_log_dir)
|
|
383
|
-
|
|
384
|
-
@property
|
|
385
|
-
def site_log_path(self) -> Path:
|
|
386
|
-
"""Log path shared by users."""
|
|
387
|
-
return Path(self.site_log_dir)
|
|
388
|
-
|
|
389
|
-
@property
|
|
390
|
-
def user_documents_path(self) -> Path:
|
|
391
|
-
"""Documents path tied to the user."""
|
|
392
|
-
return Path(self.user_documents_dir)
|
|
393
|
-
|
|
394
|
-
@property
|
|
395
|
-
def user_downloads_path(self) -> Path:
|
|
396
|
-
"""Downloads path tied to the user."""
|
|
397
|
-
return Path(self.user_downloads_dir)
|
|
398
|
-
|
|
399
|
-
@property
|
|
400
|
-
def user_pictures_path(self) -> Path:
|
|
401
|
-
"""Pictures path tied to the user."""
|
|
402
|
-
return Path(self.user_pictures_dir)
|
|
403
|
-
|
|
404
|
-
@property
|
|
405
|
-
def user_videos_path(self) -> Path:
|
|
406
|
-
"""Videos path tied to the user."""
|
|
407
|
-
return Path(self.user_videos_dir)
|
|
408
|
-
|
|
409
|
-
@property
|
|
410
|
-
def user_music_path(self) -> Path:
|
|
411
|
-
"""Music path tied to the user."""
|
|
412
|
-
return Path(self.user_music_dir)
|
|
413
|
-
|
|
414
|
-
@property
|
|
415
|
-
def user_desktop_path(self) -> Path:
|
|
416
|
-
"""Desktop path tied to the user."""
|
|
417
|
-
return Path(self.user_desktop_dir)
|
|
418
|
-
|
|
419
|
-
@property
|
|
420
|
-
def user_projects_path(self) -> Path:
|
|
421
|
-
"""Projects path tied to the user."""
|
|
422
|
-
return Path(self.user_projects_dir)
|
|
423
|
-
|
|
424
|
-
@property
|
|
425
|
-
def user_publicshare_path(self) -> Path:
|
|
426
|
-
"""Public share path tied to the user."""
|
|
427
|
-
return Path(self.user_publicshare_dir)
|
|
428
|
-
|
|
429
|
-
@property
|
|
430
|
-
def user_templates_path(self) -> Path:
|
|
431
|
-
"""Templates path tied to the user."""
|
|
432
|
-
return Path(self.user_templates_dir)
|
|
433
|
-
|
|
434
|
-
@property
|
|
435
|
-
def user_fonts_path(self) -> Path:
|
|
436
|
-
"""Fonts path tied to the user."""
|
|
437
|
-
return Path(self.user_fonts_dir)
|
|
438
|
-
|
|
439
|
-
@property
|
|
440
|
-
def user_preference_path(self) -> Path:
|
|
441
|
-
"""Preference path tied to the user."""
|
|
442
|
-
return Path(self.user_preference_dir)
|
|
443
|
-
|
|
444
|
-
@property
|
|
445
|
-
def user_bin_path(self) -> Path:
|
|
446
|
-
"""Bin path tied to the user."""
|
|
447
|
-
return Path(self.user_bin_dir)
|
|
400
|
+
def user_applications_dir(self) -> str:
|
|
401
|
+
"""Applications directory tied to the user."""
|
|
448
402
|
|
|
449
403
|
@property
|
|
450
|
-
def
|
|
451
|
-
"""
|
|
452
|
-
return Path(self.
|
|
404
|
+
def site_applications_path(self) -> Path:
|
|
405
|
+
"""Applications path shared by users. Only return the first item, even if ``multipath`` is set to ``True``."""
|
|
406
|
+
return Path(self._site_applications_dirs[0])
|
|
453
407
|
|
|
454
408
|
@property
|
|
455
|
-
def
|
|
456
|
-
|
|
457
|
-
return Path(self.user_applications_dir)
|
|
409
|
+
def _site_applications_dirs(self) -> list[str]:
|
|
410
|
+
return [self.site_applications_dir]
|
|
458
411
|
|
|
459
412
|
@property
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
413
|
+
@abstractmethod
|
|
414
|
+
def site_applications_dir(self) -> str:
|
|
415
|
+
"""Applications directory shared by users."""
|
|
463
416
|
|
|
464
417
|
@property
|
|
465
418
|
def user_runtime_path(self) -> Path:
|
|
466
419
|
"""Runtime path tied to the user."""
|
|
467
420
|
return Path(self.user_runtime_dir)
|
|
468
421
|
|
|
422
|
+
@property
|
|
423
|
+
@abstractmethod
|
|
424
|
+
def user_runtime_dir(self) -> str:
|
|
425
|
+
"""Runtime directory tied to the user."""
|
|
426
|
+
|
|
469
427
|
@property
|
|
470
428
|
def site_runtime_path(self) -> Path:
|
|
471
429
|
"""Runtime path shared by users."""
|
|
472
430
|
return Path(self.site_runtime_dir)
|
|
473
431
|
|
|
432
|
+
@property
|
|
433
|
+
@abstractmethod
|
|
434
|
+
def site_runtime_dir(self) -> str:
|
|
435
|
+
"""Runtime directory shared by users."""
|
|
436
|
+
|
|
437
|
+
def _append_app_name_and_version(self, *base: str, private: bool) -> str:
|
|
438
|
+
path = self._join_app_name_and_version(*base)
|
|
439
|
+
self._optionally_create_directory(path, private=private)
|
|
440
|
+
return path
|
|
441
|
+
|
|
442
|
+
def _join_app_name_and_version(self, *base: str) -> str:
|
|
443
|
+
params = list(base[1:])
|
|
444
|
+
if self.appname:
|
|
445
|
+
params.append(self.appname)
|
|
446
|
+
if self.version:
|
|
447
|
+
params.append(self.version)
|
|
448
|
+
return os.path.join(base[0], *params) # ruff:ignore[os-path-join] # preserve path separators
|
|
449
|
+
|
|
450
|
+
def _optionally_create_media_directory(self, path: str) -> None:
|
|
451
|
+
# Only called for a media directory the user configured. Media directories are often symlinks to removable or
|
|
452
|
+
# network storage, so a dangling link is returned as-is, like before ensure_exists covered them.
|
|
453
|
+
try:
|
|
454
|
+
self._optionally_create_directory(path, private=False)
|
|
455
|
+
except FileExistsError:
|
|
456
|
+
if not (directory := Path(path)).is_symlink() or directory.exists():
|
|
457
|
+
raise
|
|
458
|
+
|
|
459
|
+
def _select_site_dirs(self, dirs: list[str]) -> str:
|
|
460
|
+
# Site lists are built without touching the disk, so ensure_exists only creates what the caller gets back.
|
|
461
|
+
selected = dirs if self.multipath else dirs[:1]
|
|
462
|
+
if self.multipath and any(os.pathsep in path for path in selected):
|
|
463
|
+
# Callers split the joined string on os.pathsep, so a separator inside one entry reads as two directories.
|
|
464
|
+
msg = f"multipath cannot join site directories that contain {os.pathsep!r}, got {selected!r}"
|
|
465
|
+
raise ValueError(msg)
|
|
466
|
+
for path in selected:
|
|
467
|
+
self._optionally_create_directory(path, private=False)
|
|
468
|
+
return os.pathsep.join(selected)
|
|
469
|
+
|
|
470
|
+
def iter_config_paths(self) -> Iterator[Path]:
|
|
471
|
+
""":yields: all user and site configuration paths."""
|
|
472
|
+
for path in self.iter_config_dirs():
|
|
473
|
+
yield Path(path)
|
|
474
|
+
|
|
474
475
|
def iter_config_dirs(self) -> Iterator[str]:
|
|
475
|
-
""":
|
|
476
|
+
""":yields: all user and site configuration directories."""
|
|
476
477
|
yield from _unique(self._iter_config_dirs())
|
|
477
478
|
|
|
478
479
|
def _iter_config_dirs(self) -> Iterator[str]:
|
|
@@ -480,8 +481,24 @@ class PlatformDirsABC(ABC): # ruff:ignore[too-many-public-methods]
|
|
|
480
481
|
yield self.user_config_dir
|
|
481
482
|
yield from self._create_as_yielded(self._site_config_dirs)
|
|
482
483
|
|
|
484
|
+
@property
|
|
485
|
+
def _use_site(self) -> bool:
|
|
486
|
+
# Only Unix redirects root's user dirs to the site ones. The iterators then skip the user dir, since under
|
|
487
|
+
# multipath it is the joined site string that _unique cannot match against any single entry.
|
|
488
|
+
return False
|
|
489
|
+
|
|
490
|
+
def _create_as_yielded(self, dirs: Iterable[str]) -> Iterator[str]:
|
|
491
|
+
for path in dirs:
|
|
492
|
+
self._optionally_create_directory(path, private=False)
|
|
493
|
+
yield path
|
|
494
|
+
|
|
495
|
+
def iter_data_paths(self) -> Iterator[Path]:
|
|
496
|
+
""":yields: all user and site data paths."""
|
|
497
|
+
for path in self.iter_data_dirs():
|
|
498
|
+
yield Path(path)
|
|
499
|
+
|
|
483
500
|
def iter_data_dirs(self) -> Iterator[str]:
|
|
484
|
-
""":
|
|
501
|
+
""":yields: all user and site data directories."""
|
|
485
502
|
yield from _unique(self._iter_data_dirs())
|
|
486
503
|
|
|
487
504
|
def _iter_data_dirs(self) -> Iterator[str]:
|
|
@@ -489,8 +506,13 @@ class PlatformDirsABC(ABC): # ruff:ignore[too-many-public-methods]
|
|
|
489
506
|
yield self.user_data_dir
|
|
490
507
|
yield from self._create_as_yielded(self._site_data_dirs)
|
|
491
508
|
|
|
509
|
+
def iter_cache_paths(self) -> Iterator[Path]:
|
|
510
|
+
""":yields: all user and site cache paths."""
|
|
511
|
+
for path in self.iter_cache_dirs():
|
|
512
|
+
yield Path(path)
|
|
513
|
+
|
|
492
514
|
def iter_cache_dirs(self) -> Iterator[str]:
|
|
493
|
-
""":
|
|
515
|
+
""":yields: all user and site cache directories."""
|
|
494
516
|
yield from _unique(self._iter_cache_dirs())
|
|
495
517
|
|
|
496
518
|
def _iter_cache_dirs(self) -> Iterator[str]:
|
|
@@ -498,8 +520,13 @@ class PlatformDirsABC(ABC): # ruff:ignore[too-many-public-methods]
|
|
|
498
520
|
yield self.user_cache_dir
|
|
499
521
|
yield from self._create_as_yielded(self._site_cache_dirs)
|
|
500
522
|
|
|
523
|
+
def iter_state_paths(self) -> Iterator[Path]:
|
|
524
|
+
""":yields: all user and site state paths."""
|
|
525
|
+
for path in self.iter_state_dirs():
|
|
526
|
+
yield Path(path)
|
|
527
|
+
|
|
501
528
|
def iter_state_dirs(self) -> Iterator[str]:
|
|
502
|
-
""":
|
|
529
|
+
""":yields: all user and site state directories."""
|
|
503
530
|
yield from _unique(self._iter_state_dirs())
|
|
504
531
|
|
|
505
532
|
def _iter_state_dirs(self) -> Iterator[str]:
|
|
@@ -507,8 +534,13 @@ class PlatformDirsABC(ABC): # ruff:ignore[too-many-public-methods]
|
|
|
507
534
|
yield self.user_state_dir
|
|
508
535
|
yield self.site_state_dir
|
|
509
536
|
|
|
537
|
+
def iter_log_paths(self) -> Iterator[Path]:
|
|
538
|
+
""":yields: all user and site log paths."""
|
|
539
|
+
for path in self.iter_log_dirs():
|
|
540
|
+
yield Path(path)
|
|
541
|
+
|
|
510
542
|
def iter_log_dirs(self) -> Iterator[str]:
|
|
511
|
-
""":
|
|
543
|
+
""":yields: all user and site log directories."""
|
|
512
544
|
yield from _unique(self._iter_log_dirs())
|
|
513
545
|
|
|
514
546
|
def _iter_log_dirs(self) -> Iterator[str]:
|
|
@@ -516,8 +548,13 @@ class PlatformDirsABC(ABC): # ruff:ignore[too-many-public-methods]
|
|
|
516
548
|
yield self.user_log_dir
|
|
517
549
|
yield self.site_log_dir
|
|
518
550
|
|
|
551
|
+
def iter_runtime_paths(self) -> Iterator[Path]:
|
|
552
|
+
""":yields: all user and site runtime paths."""
|
|
553
|
+
for path in self.iter_runtime_dirs():
|
|
554
|
+
yield Path(path)
|
|
555
|
+
|
|
519
556
|
def iter_runtime_dirs(self) -> Iterator[str]:
|
|
520
|
-
""":
|
|
557
|
+
""":yields: all user and site runtime directories."""
|
|
521
558
|
yield from _unique(self._iter_runtime_dirs())
|
|
522
559
|
|
|
523
560
|
def _iter_runtime_dirs(self) -> Iterator[str]:
|
|
@@ -526,42 +563,6 @@ class PlatformDirsABC(ABC): # ruff:ignore[too-many-public-methods]
|
|
|
526
563
|
if not self._use_site:
|
|
527
564
|
yield self.site_runtime_dir
|
|
528
565
|
|
|
529
|
-
@property
|
|
530
|
-
def _use_site(self) -> bool:
|
|
531
|
-
# Only Unix redirects root's user dirs to the site ones. The iterators then skip the user dir, since under
|
|
532
|
-
# multipath it is the joined site string that _unique cannot match against any single entry.
|
|
533
|
-
return False
|
|
534
|
-
|
|
535
|
-
def iter_config_paths(self) -> Iterator[Path]:
|
|
536
|
-
""":yield: all user and site configuration paths."""
|
|
537
|
-
for path in self.iter_config_dirs():
|
|
538
|
-
yield Path(path)
|
|
539
|
-
|
|
540
|
-
def iter_data_paths(self) -> Iterator[Path]:
|
|
541
|
-
""":yield: all user and site data paths."""
|
|
542
|
-
for path in self.iter_data_dirs():
|
|
543
|
-
yield Path(path)
|
|
544
|
-
|
|
545
|
-
def iter_cache_paths(self) -> Iterator[Path]:
|
|
546
|
-
""":yield: all user and site cache paths."""
|
|
547
|
-
for path in self.iter_cache_dirs():
|
|
548
|
-
yield Path(path)
|
|
549
|
-
|
|
550
|
-
def iter_state_paths(self) -> Iterator[Path]:
|
|
551
|
-
""":yield: all user and site state paths."""
|
|
552
|
-
for path in self.iter_state_dirs():
|
|
553
|
-
yield Path(path)
|
|
554
|
-
|
|
555
|
-
def iter_log_paths(self) -> Iterator[Path]:
|
|
556
|
-
""":yield: all user and site log paths."""
|
|
557
|
-
for path in self.iter_log_dirs():
|
|
558
|
-
yield Path(path)
|
|
559
|
-
|
|
560
|
-
def iter_runtime_paths(self) -> Iterator[Path]:
|
|
561
|
-
""":yield: all user and site runtime paths."""
|
|
562
|
-
for path in self.iter_runtime_dirs():
|
|
563
|
-
yield Path(path)
|
|
564
|
-
|
|
565
566
|
def place_config_file(self, name: str | os.PathLike[str]) -> Path:
|
|
566
567
|
"""Return the path of ``name`` under `user_config_path`, creating the missing directories on the way.
|
|
567
568
|
|
|
@@ -572,6 +573,8 @@ class PlatformDirsABC(ABC): # ruff:ignore[too-many-public-methods]
|
|
|
572
573
|
|
|
573
574
|
:param name: file path relative to the user directory, e.g. ``"sub/app.toml"``.
|
|
574
575
|
|
|
576
|
+
:returns: the path of ``name`` under the user directory.
|
|
577
|
+
|
|
575
578
|
:raises ValueError: if ``name`` is empty, absolute, has a drive or climbs out through ``..``.
|
|
576
579
|
:raises RuntimeError: if the user directory starts with ``~`` because the home directory is unknown.
|
|
577
580
|
:raises OSError: if it cannot create a missing directory, e.g. one on a missing drive or network share.
|
|
@@ -579,47 +582,75 @@ class PlatformDirsABC(ABC): # ruff:ignore[too-many-public-methods]
|
|
|
579
582
|
"""
|
|
580
583
|
return self._place_file(lambda dirs: dirs.user_config_path, name)
|
|
581
584
|
|
|
585
|
+
def _place_file(self, user_path: Callable[[PlatformDirsABC], Path], name: str | os.PathLike[str]) -> Path:
|
|
586
|
+
_ensure_inside_base("name", relative := os.fspath(name))
|
|
587
|
+
if not Path(relative).parts:
|
|
588
|
+
msg = f"name must point to a file, got {relative!r}"
|
|
589
|
+
raise ValueError(msg)
|
|
590
|
+
# Under ensure_exists the lookup itself would create the user directory with the default mode, not 0o700.
|
|
591
|
+
(lookup := copy(self)).ensure_exists = False
|
|
592
|
+
# Under multipath *_dir joins the site directories with os.pathsep, so place under the single *_path.
|
|
593
|
+
_ensure_home_known(str(directory := user_path(lookup)))
|
|
594
|
+
path = directory / relative
|
|
595
|
+
if self._use_site:
|
|
596
|
+
# Site directories keep the default mode, as under ensure_exists, so other users can still read them.
|
|
597
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
598
|
+
else:
|
|
599
|
+
_make_private_directories(path.parent)
|
|
600
|
+
return path
|
|
601
|
+
|
|
582
602
|
def place_data_file(self, name: str | os.PathLike[str]) -> Path:
|
|
583
|
-
"""Like `place_config_file`, under `user_data_path`.
|
|
603
|
+
"""Like `place_config_file`, under `user_data_path`.
|
|
604
|
+
|
|
605
|
+
:param name: see `place_config_file`.
|
|
606
|
+
|
|
607
|
+
:returns: the path of ``name`` under the user data directory.
|
|
608
|
+
|
|
609
|
+
"""
|
|
584
610
|
return self._place_file(lambda dirs: dirs.user_data_path, name)
|
|
585
611
|
|
|
586
612
|
def place_cache_file(self, name: str | os.PathLike[str]) -> Path:
|
|
587
|
-
"""Like `place_config_file`, under `user_cache_path`.
|
|
613
|
+
"""Like `place_config_file`, under `user_cache_path`.
|
|
614
|
+
|
|
615
|
+
:param name: see `place_config_file`.
|
|
616
|
+
|
|
617
|
+
:returns: the path of ``name`` under the user cache directory.
|
|
618
|
+
|
|
619
|
+
"""
|
|
588
620
|
return self._place_file(lambda dirs: dirs.user_cache_path, name)
|
|
589
621
|
|
|
590
622
|
def place_state_file(self, name: str | os.PathLike[str]) -> Path:
|
|
591
|
-
"""Like `place_config_file`, under `user_state_path`.
|
|
623
|
+
"""Like `place_config_file`, under `user_state_path`.
|
|
624
|
+
|
|
625
|
+
:param name: see `place_config_file`.
|
|
626
|
+
|
|
627
|
+
:returns: the path of ``name`` under the user state directory.
|
|
628
|
+
|
|
629
|
+
"""
|
|
592
630
|
return self._place_file(lambda dirs: dirs.user_state_path, name)
|
|
593
631
|
|
|
594
632
|
def place_log_file(self, name: str | os.PathLike[str]) -> Path:
|
|
595
|
-
"""Like `place_config_file`, under `user_log_path`.
|
|
633
|
+
"""Like `place_config_file`, under `user_log_path`.
|
|
634
|
+
|
|
635
|
+
:param name: see `place_config_file`.
|
|
636
|
+
|
|
637
|
+
:returns: the path of ``name`` under the user log directory.
|
|
638
|
+
|
|
639
|
+
"""
|
|
596
640
|
return self._place_file(lambda dirs: dirs.user_log_path, name)
|
|
597
641
|
|
|
598
642
|
def place_runtime_file(self, name: str | os.PathLike[str]) -> Path:
|
|
599
643
|
"""Like `place_config_file`, under `user_runtime_path`.
|
|
600
644
|
|
|
645
|
+
:param name: see `place_config_file`.
|
|
646
|
+
|
|
647
|
+
:returns: the path of ``name`` under the user runtime directory.
|
|
648
|
+
|
|
601
649
|
:raises PermissionError: on Unix, if another user owns the temporary fallback directory.
|
|
602
650
|
|
|
603
651
|
"""
|
|
604
652
|
return self._place_file(lambda dirs: dirs.user_runtime_path, name)
|
|
605
653
|
|
|
606
|
-
def _place_file(self, user_path: Callable[[PlatformDirsABC], Path], name: str | os.PathLike[str]) -> Path:
|
|
607
|
-
_ensure_inside_base("name", relative := os.fspath(name))
|
|
608
|
-
if not Path(relative).parts:
|
|
609
|
-
msg = f"name must point to a file, got {relative!r}"
|
|
610
|
-
raise ValueError(msg)
|
|
611
|
-
# Under ensure_exists the lookup itself would create the user directory with the default mode, not 0o700.
|
|
612
|
-
(lookup := copy(self)).ensure_exists = False
|
|
613
|
-
# Under multipath *_dir joins the site directories with os.pathsep, so place under the single *_path.
|
|
614
|
-
_ensure_home_known(str(directory := user_path(lookup)))
|
|
615
|
-
path = directory / relative
|
|
616
|
-
if self._use_site:
|
|
617
|
-
# Site directories keep the default mode, as under ensure_exists, so other users can still read them.
|
|
618
|
-
path.parent.mkdir(parents=True, exist_ok=True)
|
|
619
|
-
else:
|
|
620
|
-
_make_private_directories(path.parent)
|
|
621
|
-
return path
|
|
622
|
-
|
|
623
654
|
def find_config_file(self, name: str | os.PathLike[str]) -> Path | None:
|
|
624
655
|
"""Find the first ``name`` file in :meth:`iter_config_paths` order, without creating any directory.
|
|
625
656
|
|
|
@@ -632,6 +663,14 @@ class PlatformDirsABC(ABC): # ruff:ignore[too-many-public-methods]
|
|
|
632
663
|
"""
|
|
633
664
|
return next(self._find_files(lambda dirs: dirs.iter_config_paths(), name), None)
|
|
634
665
|
|
|
666
|
+
def _find_files(
|
|
667
|
+
self, iter_paths: Callable[[PlatformDirsABC], Iterator[Path]], name: str | os.PathLike[str]
|
|
668
|
+
) -> Iterator[Path]:
|
|
669
|
+
_ensure_inside_base("name", relative := os.fspath(name))
|
|
670
|
+
# The iterators create each directory they yield under ensure_exists, and a lookup must only read the disk.
|
|
671
|
+
(lookup := copy(self)).ensure_exists = False
|
|
672
|
+
return (path for directory in iter_paths(lookup) if os.path.isfile(path := directory / relative)) # ruff:ignore[os-path-isfile] # Path.is_file raises on an unsearchable directory before Python 3.14
|
|
673
|
+
|
|
635
674
|
def find_config_files(self, name: str | os.PathLike[str]) -> list[Path]:
|
|
636
675
|
"""Find every ``name`` file in :meth:`iter_config_paths` order, without creating any directory.
|
|
637
676
|
|
|
@@ -645,55 +684,107 @@ class PlatformDirsABC(ABC): # ruff:ignore[too-many-public-methods]
|
|
|
645
684
|
return list(self._find_files(lambda dirs: dirs.iter_config_paths(), name))
|
|
646
685
|
|
|
647
686
|
def find_data_file(self, name: str | os.PathLike[str]) -> Path | None:
|
|
648
|
-
"""Like :meth:`find_config_file`, searching :meth:`iter_data_paths`.
|
|
687
|
+
"""Like :meth:`find_config_file`, searching :meth:`iter_data_paths`.
|
|
688
|
+
|
|
689
|
+
:param name: see :meth:`find_config_file`.
|
|
690
|
+
|
|
691
|
+
:returns: the first ``name`` file in the data paths, or ``None`` when no directory holds one.
|
|
692
|
+
|
|
693
|
+
"""
|
|
649
694
|
return next(self._find_files(lambda dirs: dirs.iter_data_paths(), name), None)
|
|
650
695
|
|
|
651
696
|
def find_data_files(self, name: str | os.PathLike[str]) -> list[Path]:
|
|
652
|
-
"""Like :meth:`find_config_files`, searching :meth:`iter_data_paths`.
|
|
697
|
+
"""Like :meth:`find_config_files`, searching :meth:`iter_data_paths`.
|
|
698
|
+
|
|
699
|
+
:param name: see :meth:`find_config_file`.
|
|
700
|
+
|
|
701
|
+
:returns: every ``name`` file in the data paths, in iteration order.
|
|
702
|
+
|
|
703
|
+
"""
|
|
653
704
|
return list(self._find_files(lambda dirs: dirs.iter_data_paths(), name))
|
|
654
705
|
|
|
655
706
|
def find_cache_file(self, name: str | os.PathLike[str]) -> Path | None:
|
|
656
|
-
"""Like :meth:`find_config_file`, searching :meth:`iter_cache_paths`.
|
|
707
|
+
"""Like :meth:`find_config_file`, searching :meth:`iter_cache_paths`.
|
|
708
|
+
|
|
709
|
+
:param name: see :meth:`find_config_file`.
|
|
710
|
+
|
|
711
|
+
:returns: the first ``name`` file in the cache paths, or ``None`` when no directory holds one.
|
|
712
|
+
|
|
713
|
+
"""
|
|
657
714
|
return next(self._find_files(lambda dirs: dirs.iter_cache_paths(), name), None)
|
|
658
715
|
|
|
659
716
|
def find_cache_files(self, name: str | os.PathLike[str]) -> list[Path]:
|
|
660
|
-
"""Like :meth:`find_config_files`, searching :meth:`iter_cache_paths`.
|
|
717
|
+
"""Like :meth:`find_config_files`, searching :meth:`iter_cache_paths`.
|
|
718
|
+
|
|
719
|
+
:param name: see :meth:`find_config_file`.
|
|
720
|
+
|
|
721
|
+
:returns: every ``name`` file in the cache paths, in iteration order.
|
|
722
|
+
|
|
723
|
+
"""
|
|
661
724
|
return list(self._find_files(lambda dirs: dirs.iter_cache_paths(), name))
|
|
662
725
|
|
|
663
726
|
def find_state_file(self, name: str | os.PathLike[str]) -> Path | None:
|
|
664
|
-
"""Like :meth:`find_config_file`, searching :meth:`iter_state_paths`.
|
|
727
|
+
"""Like :meth:`find_config_file`, searching :meth:`iter_state_paths`.
|
|
728
|
+
|
|
729
|
+
:param name: see :meth:`find_config_file`.
|
|
730
|
+
|
|
731
|
+
:returns: the first ``name`` file in the state paths, or ``None`` when no directory holds one.
|
|
732
|
+
|
|
733
|
+
"""
|
|
665
734
|
return next(self._find_files(lambda dirs: dirs.iter_state_paths(), name), None)
|
|
666
735
|
|
|
667
736
|
def find_state_files(self, name: str | os.PathLike[str]) -> list[Path]:
|
|
668
|
-
"""Like :meth:`find_config_files`, searching :meth:`iter_state_paths`.
|
|
737
|
+
"""Like :meth:`find_config_files`, searching :meth:`iter_state_paths`.
|
|
738
|
+
|
|
739
|
+
:param name: see :meth:`find_config_file`.
|
|
740
|
+
|
|
741
|
+
:returns: every ``name`` file in the state paths, in iteration order.
|
|
742
|
+
|
|
743
|
+
"""
|
|
669
744
|
return list(self._find_files(lambda dirs: dirs.iter_state_paths(), name))
|
|
670
745
|
|
|
671
746
|
def find_log_file(self, name: str | os.PathLike[str]) -> Path | None:
|
|
672
|
-
"""Like :meth:`find_config_file`, searching :meth:`iter_log_paths`.
|
|
747
|
+
"""Like :meth:`find_config_file`, searching :meth:`iter_log_paths`.
|
|
748
|
+
|
|
749
|
+
:param name: see :meth:`find_config_file`.
|
|
750
|
+
|
|
751
|
+
:returns: the first ``name`` file in the log paths, or ``None`` when no directory holds one.
|
|
752
|
+
|
|
753
|
+
"""
|
|
673
754
|
return next(self._find_files(lambda dirs: dirs.iter_log_paths(), name), None)
|
|
674
755
|
|
|
675
756
|
def find_log_files(self, name: str | os.PathLike[str]) -> list[Path]:
|
|
676
|
-
"""Like :meth:`find_config_files`, searching :meth:`iter_log_paths`.
|
|
757
|
+
"""Like :meth:`find_config_files`, searching :meth:`iter_log_paths`.
|
|
758
|
+
|
|
759
|
+
:param name: see :meth:`find_config_file`.
|
|
760
|
+
|
|
761
|
+
:returns: every ``name`` file in the log paths, in iteration order.
|
|
762
|
+
|
|
763
|
+
"""
|
|
677
764
|
return list(self._find_files(lambda dirs: dirs.iter_log_paths(), name))
|
|
678
765
|
|
|
679
766
|
def find_runtime_file(self, name: str | os.PathLike[str]) -> Path | None:
|
|
680
|
-
"""Like :meth:`find_config_file`, searching :meth:`iter_runtime_paths`.
|
|
681
|
-
return next(self._find_runtime_files(name), None)
|
|
767
|
+
"""Like :meth:`find_config_file`, searching :meth:`iter_runtime_paths`.
|
|
682
768
|
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
769
|
+
:param name: see :meth:`find_config_file`.
|
|
770
|
+
|
|
771
|
+
:returns: the first ``name`` file in the runtime paths, or ``None`` when no directory holds one.
|
|
772
|
+
|
|
773
|
+
"""
|
|
774
|
+
return next(self._find_runtime_files(name), None)
|
|
686
775
|
|
|
687
776
|
def _find_runtime_files(self, name: str | os.PathLike[str]) -> Iterator[Path]:
|
|
688
777
|
return self._find_files(lambda dirs: dirs.iter_runtime_paths(), name)
|
|
689
778
|
|
|
690
|
-
def
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
779
|
+
def find_runtime_files(self, name: str | os.PathLike[str]) -> list[Path]:
|
|
780
|
+
"""Like :meth:`find_config_files`, searching :meth:`iter_runtime_paths`.
|
|
781
|
+
|
|
782
|
+
:param name: see :meth:`find_config_file`.
|
|
783
|
+
|
|
784
|
+
:returns: every ``name`` file in the runtime paths, in iteration order.
|
|
785
|
+
|
|
786
|
+
"""
|
|
787
|
+
return list(self._find_runtime_files(name))
|
|
697
788
|
|
|
698
789
|
|
|
699
790
|
def _ensure_inside_base(name: str, value: str | Literal[False] | None) -> None:
|
|
@@ -713,17 +804,6 @@ def _ensure_home_known(path: str) -> None:
|
|
|
713
804
|
raise RuntimeError(msg)
|
|
714
805
|
|
|
715
806
|
|
|
716
|
-
def _unique(dirs: Iterable[str]) -> Iterator[str]:
|
|
717
|
-
""":yield: ``dirs`` in order, skipping any directory already yielded."""
|
|
718
|
-
# Lazy on purpose: under ensure_exists reading a site_*_dir creates it, so draining ``dirs`` up front would
|
|
719
|
-
# create directories for a caller that stops after the first entry.
|
|
720
|
-
seen: set[Path] = set()
|
|
721
|
-
for path in dirs:
|
|
722
|
-
if (normalized := Path(path)) not in seen:
|
|
723
|
-
seen.add(normalized)
|
|
724
|
-
yield path
|
|
725
|
-
|
|
726
|
-
|
|
727
807
|
def _make_private_directories(path: Path) -> None:
|
|
728
808
|
# XDG asks for 0o700 on each directory created on the way, while Path.mkdir(parents=True) applies it to the last.
|
|
729
809
|
try:
|
|
@@ -735,5 +815,16 @@ def _make_private_directories(path: Path) -> None:
|
|
|
735
815
|
path.mkdir(mode=0o700, exist_ok=True)
|
|
736
816
|
|
|
737
817
|
|
|
738
|
-
|
|
818
|
+
def _unique(dirs: Iterable[str]) -> Iterator[str]:
|
|
819
|
+
# :yield: ``dirs`` in order, skipping any directory already yielded.
|
|
820
|
+
# Lazy on purpose: under ensure_exists reading a site_*_dir creates it, so draining ``dirs`` up front would
|
|
821
|
+
# create directories for a caller that stops after the first entry.
|
|
822
|
+
seen: set[Path] = set()
|
|
823
|
+
for path in dirs:
|
|
824
|
+
if (normalized := Path(path)) not in seen:
|
|
825
|
+
seen.add(normalized)
|
|
826
|
+
yield path
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
class RuntimeDirWarning(UserWarning): # simplint: ignore[missing-from-all] # preserve star imports
|
|
739
830
|
"""Emitted when the Unix or macOS ``user_runtime_dir`` cannot use ``$XDG_RUNTIME_DIR``."""
|