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:
dependabot[bot] 2024-05-18 11:17:01 -07:00 committed by GitHub
parent 68bf1c70f7
commit dc9e778111
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 39 additions and 12 deletions

View file

@ -6,7 +6,7 @@ import os
import re
import sys
from functools import lru_cache
from typing import cast
from typing import TYPE_CHECKING, cast
from .api import PlatformDirsABC
@ -117,16 +117,33 @@ class Android(PlatformDirsABC):
@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"""
result: str | None = None
# type checker isn't happy with our "import android", just don't do this when type checking see
# https://stackoverflow.com/a/61394121
if not TYPE_CHECKING:
try:
# First try to get a path to android app via pyjnius
# First try to get a path to android app using python4android (if available)...
from android import mActivity # noqa: PLC0415
context = cast("android.content.Context", mActivity.getApplicationContext()) # noqa: F821
result = context.getFilesDir().getParentFile().getAbsolutePath()
except Exception: # noqa: BLE001
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: str | None = context.getFilesDir().getParentFile().getAbsolutePath()
result = context.getFilesDir().getParentFile().getAbsolutePath()
except Exception: # noqa: BLE001
# if fails find an android folder looking a path on the sys.path
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")
for path in sys.path:
if pattern.match(path):
@ -134,6 +151,16 @@ def _android_folder() -> str | None:
break
else:
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

View file

@ -12,5 +12,5 @@ __version__: str
__version_tuple__: VERSION_TUPLE
version_tuple: VERSION_TUPLE
__version__ = version = '4.2.1'
__version_tuple__ = version_tuple = (4, 2, 1)
__version__ = version = '4.2.2'
__version_tuple__ = version_tuple = (4, 2, 2)

View file

@ -25,7 +25,7 @@ MarkupSafe==2.1.5
musicbrainzngs==0.7.1
packaging==24.0
paho-mqtt==2.1.0
platformdirs==4.2.1
platformdirs==4.2.2
plexapi==4.15.12
portend==3.2.0
profilehooks==1.12.0