Bump platformdirs from 3.11.0 to 4.2.0 (#2258)

* Bump platformdirs from 3.11.0 to 4.2.0

Bumps [platformdirs](https://github.com/platformdirs/platformdirs) from 3.11.0 to 4.2.0.
- [Release notes](https://github.com/platformdirs/platformdirs/releases)
- [Changelog](https://github.com/platformdirs/platformdirs/blob/main/CHANGES.rst)
- [Commits](https://github.com/platformdirs/platformdirs/compare/3.11.0...4.2.0)

---
updated-dependencies:
- dependency-name: platformdirs
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update platformdirs==4.2.0

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>

[skip ci]
This commit is contained in:
dependabot[bot] 2024-03-24 15:23:44 -07:00 committed by GitHub
parent a4cfc6323d
commit 13eb0fd6db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 93 additions and 37 deletions

View file

@ -2,6 +2,7 @@
Utilities for determining application-specific dirs. See <https://github.com/platformdirs/platformdirs> for details and
usage.
"""
from __future__ import annotations
import os
@ -14,11 +15,7 @@ from .version import __version_tuple__ as __version_info__
if TYPE_CHECKING:
from pathlib import Path
if sys.version_info >= (3, 8): # pragma: no cover (py38+)
from typing import Literal
else: # pragma: no cover (py38+)
from typing_extensions import Literal
def _set_platform_dir_class() -> type[PlatformDirsABC]:

View file

@ -1,4 +1,5 @@
"""Main entry point."""
from __future__ import annotations
from platformdirs import PlatformDirs, __version__

View file

@ -1,4 +1,5 @@
"""Android."""
from __future__ import annotations
import os

View file

@ -1,4 +1,5 @@
"""Base API."""
from __future__ import annotations
import os
@ -7,12 +8,7 @@ from pathlib import Path
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import sys
if sys.version_info >= (3, 8): # pragma: no cover (py38+)
from typing import Literal
else: # pragma: no cover (py38+)
from typing_extensions import Literal
from typing import Iterator, Literal
class PlatformDirsABC(ABC):
@ -241,3 +237,43 @@ class PlatformDirsABC(ABC):
def site_runtime_path(self) -> Path:
""":return: runtime path shared by users"""
return Path(self.site_runtime_dir)
def iter_config_dirs(self) -> Iterator[str]:
""":yield: all user and site configuration directories."""
yield self.user_config_dir
yield self.site_config_dir
def iter_data_dirs(self) -> Iterator[str]:
""":yield: all user and site data directories."""
yield self.user_data_dir
yield self.site_data_dir
def iter_cache_dirs(self) -> Iterator[str]:
""":yield: all user and site cache directories."""
yield self.user_cache_dir
yield self.site_cache_dir
def iter_runtime_dirs(self) -> Iterator[str]:
""":yield: all user and site runtime directories."""
yield self.user_runtime_dir
yield self.site_runtime_dir
def iter_config_paths(self) -> Iterator[Path]:
""":yield: all user and site configuration paths."""
for path in self.iter_config_dirs():
yield Path(path)
def iter_data_paths(self) -> Iterator[Path]:
""":yield: all user and site data paths."""
for path in self.iter_data_dirs():
yield Path(path)
def iter_cache_paths(self) -> Iterator[Path]:
""":yield: all user and site cache paths."""
for path in self.iter_cache_dirs():
yield Path(path)
def iter_runtime_paths(self) -> Iterator[Path]:
""":yield: all user and site runtime paths."""
for path in self.iter_runtime_dirs():
yield Path(path)

View file

@ -1,4 +1,5 @@
"""macOS."""
from __future__ import annotations
import os.path

View file

@ -1,10 +1,12 @@
"""Unix."""
from __future__ import annotations
import os
import sys
from configparser import ConfigParser
from pathlib import Path
from typing import Iterator
from .api import PlatformDirsABC
@ -43,24 +45,24 @@ class Unix(PlatformDirsABC):
return self._append_app_name_and_version(path)
@property
def site_data_dir(self) -> str:
"""
:return: data directories shared by users (if `multipath <platformdirs.api.PlatformDirsABC.multipath>` is
enabled and ``XDG_DATA_DIR`` is set and a multi path the response is also a multi path separated by the OS
path separator), e.g. ``/usr/local/share/$appname/$version`` or ``/usr/share/$appname/$version``
"""
# XDG default for $XDG_DATA_DIRS; only first, if multipath is False
def _site_data_dirs(self) -> list[str]:
path = os.environ.get("XDG_DATA_DIRS", "")
if not path.strip():
path = f"/usr/local/share{os.pathsep}/usr/share"
return self._with_multi_path(path)
return [self._append_app_name_and_version(p) for p in path.split(os.pathsep)]
def _with_multi_path(self, path: str) -> str:
path_list = path.split(os.pathsep)
@property
def site_data_dir(self) -> str:
"""
:return: data directories shared by users (if `multipath <platformdirs.api.PlatformDirsABC.multipath>` is
enabled and ``XDG_DATA_DIRS`` is set and a multi path the response is also a multi path separated by the
OS path separator), e.g. ``/usr/local/share/$appname/$version`` or ``/usr/share/$appname/$version``
"""
# XDG default for $XDG_DATA_DIRS; only first, if multipath is False
dirs = self._site_data_dirs
if not self.multipath:
path_list = path_list[0:1]
path_list = [self._append_app_name_and_version(os.path.expanduser(p)) for p in path_list] # noqa: PTH111
return os.pathsep.join(path_list)
return dirs[0]
return os.pathsep.join(dirs)
@property
def user_config_dir(self) -> str:
@ -74,17 +76,24 @@ class Unix(PlatformDirsABC):
return self._append_app_name_and_version(path)
@property
def site_config_dir(self) -> str:
"""
:return: config directories shared by users (if `multipath <platformdirs.api.PlatformDirsABC.multipath>`
is enabled and ``XDG_DATA_DIR`` is set and a multi path the response is also a multi path separated by the OS
path separator), e.g. ``/etc/xdg/$appname/$version``
"""
# XDG default for $XDG_CONFIG_DIRS only first, if multipath is False
def _site_config_dirs(self) -> list[str]:
path = os.environ.get("XDG_CONFIG_DIRS", "")
if not path.strip():
path = "/etc/xdg"
return self._with_multi_path(path)
return [self._append_app_name_and_version(p) for p in path.split(os.pathsep)]
@property
def site_config_dir(self) -> str:
"""
:return: config directories shared by users (if `multipath <platformdirs.api.PlatformDirsABC.multipath>`
is enabled and ``XDG_CONFIG_DIRS`` is set and a multi path the response is also a multi path separated by
the OS path separator), e.g. ``/etc/xdg/$appname/$version``
"""
# XDG default for $XDG_CONFIG_DIRS only first, if multipath is False
dirs = self._site_config_dirs
if not self.multipath:
return dirs[0]
return os.pathsep.join(dirs)
@property
def user_cache_dir(self) -> str:
@ -99,8 +108,8 @@ class Unix(PlatformDirsABC):
@property
def site_cache_dir(self) -> str:
""":return: cache directory shared by users, e.g. ``/var/tmp/$appname/$version``"""
return self._append_app_name_and_version("/var/tmp") # noqa: S108
""":return: 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:
@ -215,6 +224,16 @@ class Unix(PlatformDirsABC):
directory = directory.split(os.pathsep)[0]
return Path(directory)
def iter_config_dirs(self) -> Iterator[str]:
""":yield: all user and site configuration directories."""
yield self.user_config_dir
yield from self._site_config_dirs
def iter_data_dirs(self) -> Iterator[str]:
""":yield: all user and site data directories."""
yield self.user_data_dir
yield from self._site_data_dirs
def _get_user_media_dir(env_var: str, fallback_tilde_path: str) -> str:
media_dir = _get_user_dirs_folder(env_var)

View file

@ -12,5 +12,5 @@ __version__: str
__version_tuple__: VERSION_TUPLE
version_tuple: VERSION_TUPLE
__version__ = version = '3.11.0'
__version_tuple__ = version_tuple = (3, 11, 0)
__version__ = version = '4.2.0'
__version_tuple__ = version_tuple = (4, 2, 0)

View file

@ -1,4 +1,5 @@
"""Windows."""
from __future__ import annotations
import ctypes

View file

@ -27,7 +27,7 @@ MarkupSafe==2.1.3
musicbrainzngs==0.7.1
packaging==23.1
paho-mqtt==1.6.1
platformdirs==3.11.0
platformdirs==4.2.0
plexapi==4.15.10
portend==3.2.0
profilehooks==1.12.0