Skip to content

Commit

Permalink
πŸ“‚πŸ†™ Switch from appdirs to platformdirs (#817)
Browse files Browse the repository at this point in the history
* πŸ“‚ Exchange all instances of `appdirs` with `platformdirs`

* 🧹 Lint with black

* πŸ”ƒ iDon'tSort

* πŸ”  Sort imports Alphabetically
  • Loading branch information
Kezzsim authored Nov 21, 2024
1 parent 0143d81 commit cb31d56
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/source/how-to/profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ including:

Tiled will also look for profiles in locations specific to the
operating system and the software environment,
[in accordance](https://pypi.org/project/appdirs/) with
[in accordance](https://pypi.org/project/platformdirs/) with
[standards](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html).
To see the full list on your system:

Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ all = [
"aiosqlite",
"alembic",
"anyio",
"appdirs",
"asgi-correlation-id",
"asyncpg",
"awkward >=2.4.3",
Expand Down Expand Up @@ -75,6 +74,7 @@ all = [
"packaging",
"pandas",
"pillow",
"platformdirs",
"prometheus_client",
"pyarrow",
"pydantic >=2, <3",
Expand Down Expand Up @@ -102,7 +102,6 @@ array = [
]
# This is the "kichen sink" fully-featured client dependency set.
client = [
"appdirs",
"awkward >=2.4.3",
"blosc2; python_version >= '3.10'",
"dask[array]",
Expand All @@ -118,6 +117,7 @@ client = [
"numpy",
"orjson",
"pandas",
"platformdirs",
"pyarrow",
"pyyaml",
"rich",
Expand Down Expand Up @@ -173,14 +173,14 @@ formats = [
]
# These are the requirements needed for basic client functionality.
minimal-client = [
"appdirs",
"entrypoints",
"httpx >=0.20.0,!=0.23.1",
"json-merge-patch",
"jsonpatch",
"jsonschema",
"msgpack >=1.0.0",
"orjson",
"platformdirs",
"pyyaml",
"rich",
"typer",
Expand All @@ -192,7 +192,6 @@ minimal-server = [
"aiosqlite",
"alembic",
"anyio",
"appdirs",
"asgi-correlation-id",
"cachetools",
"canonicaljson",
Expand All @@ -207,6 +206,7 @@ minimal-server = [
"msgpack >=1.0.0",
"orjson",
"packaging",
"platformdirs",
"prometheus_client",
"pydantic >=2, <3",
"pydantic-settings >=2, <3",
Expand All @@ -227,7 +227,6 @@ server = [
"aiosqlite",
"alembic",
"anyio",
"appdirs",
"asgi-correlation-id",
"asyncpg",
"awkward >=2.4.3",
Expand Down Expand Up @@ -255,6 +254,7 @@ server = [
"packaging",
"pandas",
"pillow",
"platformdirs",
"prometheus_client",
"pyarrow",
"pydantic >=2, <3",
Expand Down
4 changes: 2 additions & 2 deletions tiled/client/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from functools import wraps
from pathlib import Path

import appdirs
import httpx
import platformdirs

from .utils import SerializableLock, TiledResponse

Expand Down Expand Up @@ -187,7 +187,7 @@ def __init__(
# Resolve this here, not at module scope, because the test suite
# injects TILED_CACHE_DIR env var to use a temporary directory.
TILED_CACHE_DIR = Path(
os.getenv("TILED_CACHE_DIR", appdirs.user_cache_dir("tiled"))
os.getenv("TILED_CACHE_DIR", platformdirs.user_cache_dir("tiled"))
)
# TODO Detect filesystem of TILED_CACHE_DIR. If it is a networked filesystem
# use a temporary database instead.
Expand Down
6 changes: 3 additions & 3 deletions tiled/client/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import warnings
from pathlib import Path

import appdirs
import httpx
import platformdirs

from .._version import __version__ as tiled_version
from ..utils import UNSET, DictView
Expand Down Expand Up @@ -65,7 +65,7 @@ def __init__(
# Resolve this here, not at module scope, because the test suite
# injects TILED_CACHE_DIR env var to use a temporary directory.
TILED_CACHE_DIR = Path(
os.getenv("TILED_CACHE_DIR", appdirs.user_cache_dir("tiled"))
os.getenv("TILED_CACHE_DIR", platformdirs.user_cache_dir("tiled"))
)
headers.setdefault("accept-encoding", ACCEPT_ENCODING)
# Set the User Agent to help the server fail informatively if the client
Expand Down Expand Up @@ -915,7 +915,7 @@ def _default_identity_filepath(api_uri):
# Resolve this here, not at module scope, because the test suite
# injects TILED_CACHE_DIR env var to use a temporary directory.
TILED_CACHE_DIR = Path(
os.getenv("TILED_CACHE_DIR", appdirs.user_cache_dir("tiled"))
os.getenv("TILED_CACHE_DIR", platformdirs.user_cache_dir("tiled"))
)
return Path(
TILED_CACHE_DIR, "default_identities", urllib.parse.quote_plus(str(api_uri))
Expand Down
10 changes: 7 additions & 3 deletions tiled/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
It contains several functions that are factored to facilitate testing,
but the user-facing functionality is striaghtforward.
"""

import collections
import collections.abc
import os
Expand All @@ -14,8 +15,8 @@
from functools import lru_cache
from pathlib import Path

import appdirs
import jsonschema
import platformdirs

from .utils import parse

Expand Down Expand Up @@ -49,15 +50,18 @@ def schema():
), # hard-coded system path
Path(
os.getenv(
"TILED_SITE_PROFILES", Path(appdirs.site_config_dir("tiled"), "profiles")
"TILED_SITE_PROFILES",
Path(platformdirs.site_config_dir("tiled"), "profiles"),
)
), # XDG-compliant system path
Path(sys.prefix, "etc", "tiled", "profiles"), # environment
Path(
os.getenv("TILED_PROFILES", Path.home() / ".config/tiled/profiles")
), # hard-coded user path
Path(
os.getenv("TILED_PROFILES", Path(appdirs.user_config_dir("tiled"), "profiles"))
os.getenv(
"TILED_PROFILES", Path(platformdirs.user_config_dir("tiled"), "profiles")
)
), # system-dependent user path
]
# Remove duplicates (i.e. if XDG and hard-coded are the same on this system).
Expand Down

0 comments on commit cb31d56

Please sign in to comment.