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 Utilities for determining application-specific dirs. See <https://github.com/platformdirs/platformdirs> for details and
usage. usage.
""" """
from __future__ import annotations from __future__ import annotations
import os import os
@ -14,11 +15,7 @@ from .version import __version_tuple__ as __version_info__
if TYPE_CHECKING: if TYPE_CHECKING:
from pathlib import Path from pathlib import Path
from typing import Literal
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]: def _set_platform_dir_class() -> type[PlatformDirsABC]:

View file

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

View file

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

View file

@ -1,4 +1,5 @@
"""Base API.""" """Base API."""
from __future__ import annotations from __future__ import annotations
import os import os
@ -7,12 +8,7 @@ from pathlib import Path
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
if TYPE_CHECKING: if TYPE_CHECKING:
import sys from typing import Iterator, Literal
if sys.version_info >= (3, 8): # pragma: no cover (py38+)
from typing import Literal
else: # pragma: no cover (py38+)
from typing_extensions import Literal
class PlatformDirsABC(ABC): class PlatformDirsABC(ABC):
@ -241,3 +237,43 @@ class PlatformDirsABC(ABC):
def site_runtime_path(self) -> Path: def site_runtime_path(self) -> Path:
""":return: runtime path shared by users""" """:return: runtime path shared by users"""
return Path(self.site_runtime_dir) 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.""" """macOS."""
from __future__ import annotations from __future__ import annotations
import os.path import os.path

View file

@ -1,10 +1,12 @@
"""Unix.""" """Unix."""
from __future__ import annotations from __future__ import annotations
import os import os
import sys import sys
from configparser import ConfigParser from configparser import ConfigParser
from pathlib import Path from pathlib import Path
from typing import Iterator
from .api import PlatformDirsABC from .api import PlatformDirsABC
@ -43,24 +45,24 @@ class Unix(PlatformDirsABC):
return self._append_app_name_and_version(path) return self._append_app_name_and_version(path)
@property @property
def site_data_dir(self) -> str: def _site_data_dirs(self) -> list[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
path = os.environ.get("XDG_DATA_DIRS", "") path = os.environ.get("XDG_DATA_DIRS", "")
if not path.strip(): if not path.strip():
path = f"/usr/local/share{os.pathsep}/usr/share" 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: @property
path_list = path.split(os.pathsep) 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: if not self.multipath:
path_list = path_list[0:1] return dirs[0]
path_list = [self._append_app_name_and_version(os.path.expanduser(p)) for p in path_list] # noqa: PTH111 return os.pathsep.join(dirs)
return os.pathsep.join(path_list)
@property @property
def user_config_dir(self) -> str: def user_config_dir(self) -> str:
@ -74,17 +76,24 @@ class Unix(PlatformDirsABC):
return self._append_app_name_and_version(path) return self._append_app_name_and_version(path)
@property @property
def site_config_dir(self) -> str: def _site_config_dirs(self) -> list[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
path = os.environ.get("XDG_CONFIG_DIRS", "") path = os.environ.get("XDG_CONFIG_DIRS", "")
if not path.strip(): if not path.strip():
path = "/etc/xdg" 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 @property
def user_cache_dir(self) -> str: def user_cache_dir(self) -> str:
@ -99,8 +108,8 @@ class Unix(PlatformDirsABC):
@property @property
def site_cache_dir(self) -> str: def site_cache_dir(self) -> str:
""":return: cache directory shared by users, e.g. ``/var/tmp/$appname/$version``""" """:return: cache directory shared by users, e.g. ``/var/cache/$appname/$version``"""
return self._append_app_name_and_version("/var/tmp") # noqa: S108 return self._append_app_name_and_version("/var/cache")
@property @property
def user_state_dir(self) -> str: def user_state_dir(self) -> str:
@ -215,6 +224,16 @@ class Unix(PlatformDirsABC):
directory = directory.split(os.pathsep)[0] directory = directory.split(os.pathsep)[0]
return Path(directory) 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: def _get_user_media_dir(env_var: str, fallback_tilde_path: str) -> str:
media_dir = _get_user_dirs_folder(env_var) 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_tuple: VERSION_TUPLE version_tuple: VERSION_TUPLE
__version__ = version = '3.11.0' __version__ = version = '4.2.0'
__version_tuple__ = version_tuple = (3, 11, 0) __version_tuple__ = version_tuple = (4, 2, 0)

View file

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

View file

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