mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-16 02:02:58 -07:00
Bump platformdirs from 4.2.1 to 4.2.2 (#2324)
* Bump platformdirs from 4.2.1 to 4.2.2 Bumps [platformdirs](https://github.com/platformdirs/platformdirs) from 4.2.1 to 4.2.2. - [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/4.2.1...4.2.2) --- updated-dependencies: - dependency-name: platformdirs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Update platformdirs==4.2.2 --------- 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
68bf1c70f7
commit
dc9e778111
3 changed files with 39 additions and 12 deletions
|
@ -6,7 +6,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from typing import cast
|
from typing import TYPE_CHECKING, cast
|
||||||
|
|
||||||
from .api import PlatformDirsABC
|
from .api import PlatformDirsABC
|
||||||
|
|
||||||
|
@ -117,16 +117,33 @@ class Android(PlatformDirsABC):
|
||||||
|
|
||||||
|
|
||||||
@lru_cache(maxsize=1)
|
@lru_cache(maxsize=1)
|
||||||
def _android_folder() -> str | None:
|
def _android_folder() -> str | None: # noqa: C901, PLR0912
|
||||||
""":return: base folder for the Android OS or None if it cannot be found"""
|
""":return: base folder for the Android OS or None if it cannot be found"""
|
||||||
try:
|
result: str | None = None
|
||||||
# First try to get a path to android app via pyjnius
|
# type checker isn't happy with our "import android", just don't do this when type checking see
|
||||||
from jnius import autoclass # noqa: PLC0415
|
# https://stackoverflow.com/a/61394121
|
||||||
|
if not TYPE_CHECKING:
|
||||||
|
try:
|
||||||
|
# First try to get a path to android app using python4android (if available)...
|
||||||
|
from android import mActivity # noqa: PLC0415
|
||||||
|
|
||||||
context = autoclass("android.content.Context")
|
context = cast("android.content.Context", mActivity.getApplicationContext()) # noqa: F821
|
||||||
result: str | None = context.getFilesDir().getParentFile().getAbsolutePath()
|
result = context.getFilesDir().getParentFile().getAbsolutePath()
|
||||||
except Exception: # noqa: BLE001
|
except Exception: # noqa: BLE001
|
||||||
# if fails find an android folder looking a path on the sys.path
|
result = None
|
||||||
|
if result is None:
|
||||||
|
try:
|
||||||
|
# ...and fall back to using plain pyjnius, if python4android isn't available or doesn't deliver any useful
|
||||||
|
# result...
|
||||||
|
from jnius import autoclass # noqa: PLC0415
|
||||||
|
|
||||||
|
context = autoclass("android.content.Context")
|
||||||
|
result = context.getFilesDir().getParentFile().getAbsolutePath()
|
||||||
|
except Exception: # noqa: BLE001
|
||||||
|
result = None
|
||||||
|
if result is None:
|
||||||
|
# and if that fails, too, find an android folder looking at path on the sys.path
|
||||||
|
# warning: only works for apps installed under /data, not adopted storage etc.
|
||||||
pattern = re.compile(r"/data/(data|user/\d+)/(.+)/files")
|
pattern = re.compile(r"/data/(data|user/\d+)/(.+)/files")
|
||||||
for path in sys.path:
|
for path in sys.path:
|
||||||
if pattern.match(path):
|
if pattern.match(path):
|
||||||
|
@ -134,6 +151,16 @@ def _android_folder() -> str | None:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
result = None
|
result = None
|
||||||
|
if result is None:
|
||||||
|
# one last try: find an android folder looking at path on the sys.path taking adopted storage paths into
|
||||||
|
# account
|
||||||
|
pattern = re.compile(r"/mnt/expand/[a-fA-F0-9-]{36}/(data|user/\d+)/(.+)/files")
|
||||||
|
for path in sys.path:
|
||||||
|
if pattern.match(path):
|
||||||
|
result = path.split("/files")[0]
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
result = None
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,5 +12,5 @@ __version__: str
|
||||||
__version_tuple__: VERSION_TUPLE
|
__version_tuple__: VERSION_TUPLE
|
||||||
version_tuple: VERSION_TUPLE
|
version_tuple: VERSION_TUPLE
|
||||||
|
|
||||||
__version__ = version = '4.2.1'
|
__version__ = version = '4.2.2'
|
||||||
__version_tuple__ = version_tuple = (4, 2, 1)
|
__version_tuple__ = version_tuple = (4, 2, 2)
|
||||||
|
|
|
@ -25,7 +25,7 @@ MarkupSafe==2.1.5
|
||||||
musicbrainzngs==0.7.1
|
musicbrainzngs==0.7.1
|
||||||
packaging==24.0
|
packaging==24.0
|
||||||
paho-mqtt==2.1.0
|
paho-mqtt==2.1.0
|
||||||
platformdirs==4.2.1
|
platformdirs==4.2.2
|
||||||
plexapi==4.15.12
|
plexapi==4.15.12
|
||||||
portend==3.2.0
|
portend==3.2.0
|
||||||
profilehooks==1.12.0
|
profilehooks==1.12.0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue