mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 21:51:14 -07:00
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:
parent
a4cfc6323d
commit
13eb0fd6db
9 changed files with 93 additions and 37 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue