Skip to content

Commit cbe7033

Browse files
Merge pull request #33 from jugmac00/replace-appdirs
Replace unmaintained appdirs with platformdirs
2 parents c172fa0 + def2980 commit cbe7033

File tree

5 files changed

+30
-33
lines changed

5 files changed

+30
-33
lines changed

craft_cli/messages.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from datetime import datetime
3434
from typing import Literal, Optional, TextIO, Union
3535

36-
import appdirs
36+
import platformdirs
3737

3838
try:
3939
import win32pipe # type: ignore
@@ -92,7 +92,7 @@ def _get_log_filepath(appname: str) -> pathlib.Path:
9292
The app name is used for both the directory where the logs are located and each log name.
9393
9494
Rules:
95-
- use an appdirs provided directory
95+
- use an platformdirs provided directory
9696
- base filename is <appname>.<timestamp with microseconds>.log
9797
- it rotates until it gets to reaches :data:`._MAX_LOG_FILES`
9898
- after limit is achieved, remove the exceeding files
@@ -101,7 +101,7 @@ def _get_log_filepath(appname: str) -> pathlib.Path:
101101
Existing files are not renamed (no need, as each name is unique) nor gzipped (they may
102102
be currently in use by another process).
103103
"""
104-
basedir = pathlib.Path(appdirs.user_log_dir(appname))
104+
basedir = pathlib.Path(platformdirs.user_log_dir(appname))
105105
filename = f"{appname}-{datetime.now():%Y%m%d-%H%M%S.%f}.log"
106106

107107
# ensure the basedir is there

requirements-dev.txt

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,67 @@
11
alabaster==0.7.12
2-
appdirs==1.4.4
3-
appdirs-stubs==0.1.0
4-
astroid==2.8.3
2+
astroid==2.8.4
53
attrs==21.2.0
64
autoflake==1.4
75
Babel==2.9.1
8-
backports.entry-points-selectable==1.1.0
9-
black==21.9b0
6+
backports.entry-points-selectable==1.1.1
7+
black==21.10b0
108
bleach==4.1.0
119
certifi==2021.10.8
1210
cffi==1.15.0
1311
charset-normalizer==2.0.7
1412
click==8.0.3
1513
codespell==2.1.0
1614
colorama==0.4.4
17-
coverage==6.0.2
15+
coverage==6.1.1
1816
cryptography==35.0.0
1917
distlib==0.3.3
2018
docutils==0.17.1
21-
filelock==3.3.1
19+
filelock==3.3.2
2220
flake8==4.0.1
2321
idna==3.3
24-
imagesize==1.2.0
25-
importlib-metadata==4.8.1
22+
imagesize==1.3.0
23+
importlib-metadata==4.8.2
2624
iniconfig==1.1.1
27-
isort==5.9.3
25+
isort==5.10.1
2826
jeepney==0.7.1
29-
Jinja2==3.0.2
30-
jsonpointer==2.1
27+
Jinja2==3.0.3
28+
jsonpointer==2.2
3129
keyring==23.2.1
3230
lazy-object-proxy==1.6.0
3331
MarkupSafe==2.0.1
3432
mccabe==0.6.1
3533
mypy==0.910
3634
mypy-extensions==0.4.3
37-
packaging==21.0
35+
packaging==21.2
3836
pathspec==0.9.0
3937
pkginfo==1.7.1
4038
platformdirs==2.4.0
4139
pluggy==1.0.0
42-
py==1.10.0
40+
py==1.11.0
4341
pycodestyle==2.8.0
44-
pycparser==2.20
42+
pycparser==2.21
4543
pydantic==1.8.2
4644
pydocstyle==6.1.1
4745
pyflakes==2.4.0
4846
Pygments==2.10.0
4947
pylint==2.11.1
5048
pylint-fixme-info==1.0.2
5149
pylint-pytest==1.1.2
52-
pyparsing==3.0.1
50+
pyparsing==2.4.7
5351
pytest==6.2.5
5452
pytest-mock==3.6.1
55-
pytest-subprocess==1.3.0
53+
pytest-subprocess==1.3.2
5654
pytz==2021.3
5755
PyYAML==6.0
5856
readme-renderer==30.0
59-
regex==2021.10.23
57+
regex==2021.11.10
6058
requests==2.26.0
6159
requests-toolbelt==0.9.1
6260
rfc3986==1.5.0
6361
SecretStorage==3.3.1
6462
six==1.16.0
6563
snowballstemmer==2.1.0
66-
Sphinx==4.2.0
64+
Sphinx==4.3.0
6765
sphinx-autodoc-typehints==1.12.0
6866
sphinx-jsonschema==1.16.11
6967
sphinx-pydantic==0.1.1
@@ -78,13 +76,13 @@ toml==0.10.2
7876
tomli==1.2.2
7977
tox==3.24.4
8078
tqdm==4.62.3
81-
twine==3.4.2
79+
twine==3.6.0
8280
types-PyYAML==6.0.0
83-
types-requests==2.25.11
81+
types-requests==2.26.0
8482
types-setuptools==57.4.2
8583
typing-extensions==3.10.0.2
8684
urllib3==1.26.7
87-
virtualenv==20.9.0
85+
virtualenv==20.10.0
8886
webencodings==0.5.1
89-
wrapt==1.13.2
87+
wrapt==1.13.3
9088
zipp==3.6.0

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
appdirs==1.4.4
1+
platformdirs==2.4.0
22
pydantic==1.8.2
33
PyYAML==6.0
44
typing-extensions==3.10.0.2

setup.cfg

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ include_package_data = True
2828
packages = find:
2929
zip_safe = False
3030
install_requires =
31-
appdirs
31+
platformdirs
3232
pydantic
3333
pyyaml
3434
pywin32; sys_platform == "win32"
@@ -46,7 +46,6 @@ release =
4646
twine
4747
wheel
4848
test =
49-
appdirs-stubs
5049
black
5150
codespell
5251
coverage

tests/unit/test_messages_helpers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import time
2424
from unittest.mock import MagicMock, call
2525

26-
import appdirs
26+
import platformdirs
2727
import pytest
2828

2929
from craft_cli import messages
@@ -43,10 +43,10 @@
4343

4444
@pytest.fixture
4545
def test_log_dir(tmp_path, monkeypatch):
46-
"""Provide a test log filepath, also fixing appdirs to use a temp dir."""
46+
"""Provide a test log filepath, also fixing platformdirs to use a temp dir."""
4747
dirpath = tmp_path / "testlogdir"
4848
dirpath.mkdir()
49-
monkeypatch.setattr(appdirs, "user_log_dir", lambda appname: dirpath / appname)
49+
monkeypatch.setattr(platformdirs, "user_log_dir", lambda appname: dirpath / appname)
5050
return dirpath
5151

5252

@@ -158,7 +158,7 @@ def test_getlogpath_ignore_other_files(test_log_dir, monkeypatch):
158158
def test_getlogpath_deep_dirs(tmp_path, monkeypatch):
159159
"""The log directory is inside a path that does not exist yet."""
160160
dirpath = tmp_path / "foo" / "bar" / "testlogdir"
161-
monkeypatch.setattr(appdirs, "user_log_dir", lambda appname: dirpath / appname)
161+
monkeypatch.setattr(platformdirs, "user_log_dir", lambda appname: dirpath / appname)
162162
fpath = _get_log_filepath("testapp")
163163

164164
# check the file is inside the proper dir and that it exists

0 commit comments

Comments
 (0)