Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace unmaintained appdirs with platformdirs #33

Merged
merged 1 commit into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions craft_cli/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from datetime import datetime
from typing import Literal, Optional, TextIO, Union

import appdirs
import platformdirs

try:
import win32pipe # type: ignore
Expand Down Expand Up @@ -92,7 +92,7 @@ def _get_log_filepath(appname: str) -> pathlib.Path:
The app name is used for both the directory where the logs are located and each log name.

Rules:
- use an appdirs provided directory
- use an platformdirs provided directory
- base filename is <appname>.<timestamp with microseconds>.log
- it rotates until it gets to reaches :data:`._MAX_LOG_FILES`
- after limit is achieved, remove the exceeding files
Expand All @@ -101,7 +101,7 @@ def _get_log_filepath(appname: str) -> pathlib.Path:
Existing files are not renamed (no need, as each name is unique) nor gzipped (they may
be currently in use by another process).
"""
basedir = pathlib.Path(appdirs.user_log_dir(appname))
basedir = pathlib.Path(platformdirs.user_log_dir(appname))
filename = f"{appname}-{datetime.now():%Y%m%d-%H%M%S.%f}.log"

# ensure the basedir is there
Expand Down
44 changes: 21 additions & 23 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,69 +1,67 @@
alabaster==0.7.12
appdirs==1.4.4
appdirs-stubs==0.1.0
astroid==2.8.3
astroid==2.8.4
attrs==21.2.0
autoflake==1.4
Babel==2.9.1
backports.entry-points-selectable==1.1.0
black==21.9b0
backports.entry-points-selectable==1.1.1
black==21.10b0
bleach==4.1.0
certifi==2021.10.8
cffi==1.15.0
charset-normalizer==2.0.7
click==8.0.3
codespell==2.1.0
colorama==0.4.4
coverage==6.0.2
coverage==6.1.1
cryptography==35.0.0
distlib==0.3.3
docutils==0.17.1
filelock==3.3.1
filelock==3.3.2
flake8==4.0.1
idna==3.3
imagesize==1.2.0
importlib-metadata==4.8.1
imagesize==1.3.0
importlib-metadata==4.8.2
iniconfig==1.1.1
isort==5.9.3
isort==5.10.1
jeepney==0.7.1
Jinja2==3.0.2
jsonpointer==2.1
Jinja2==3.0.3
jsonpointer==2.2
keyring==23.2.1
lazy-object-proxy==1.6.0
MarkupSafe==2.0.1
mccabe==0.6.1
mypy==0.910
mypy-extensions==0.4.3
packaging==21.0
packaging==21.2
pathspec==0.9.0
pkginfo==1.7.1
platformdirs==2.4.0
pluggy==1.0.0
py==1.10.0
py==1.11.0
pycodestyle==2.8.0
pycparser==2.20
pycparser==2.21
pydantic==1.8.2
pydocstyle==6.1.1
pyflakes==2.4.0
Pygments==2.10.0
pylint==2.11.1
pylint-fixme-info==1.0.2
pylint-pytest==1.1.2
pyparsing==3.0.1
pyparsing==2.4.7
pytest==6.2.5
pytest-mock==3.6.1
pytest-subprocess==1.3.0
pytest-subprocess==1.3.2
pytz==2021.3
PyYAML==6.0
readme-renderer==30.0
regex==2021.10.23
regex==2021.11.10
requests==2.26.0
requests-toolbelt==0.9.1
rfc3986==1.5.0
SecretStorage==3.3.1
six==1.16.0
snowballstemmer==2.1.0
Sphinx==4.2.0
Sphinx==4.3.0
sphinx-autodoc-typehints==1.12.0
sphinx-jsonschema==1.16.11
sphinx-pydantic==0.1.1
Expand All @@ -78,13 +76,13 @@ toml==0.10.2
tomli==1.2.2
tox==3.24.4
tqdm==4.62.3
twine==3.4.2
twine==3.6.0
types-PyYAML==6.0.0
types-requests==2.25.11
types-requests==2.26.0
types-setuptools==57.4.2
typing-extensions==3.10.0.2
urllib3==1.26.7
virtualenv==20.9.0
virtualenv==20.10.0
webencodings==0.5.1
wrapt==1.13.2
wrapt==1.13.3
zipp==3.6.0
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
appdirs==1.4.4
platformdirs==2.4.0
pydantic==1.8.2
PyYAML==6.0
typing-extensions==3.10.0.2
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ include_package_data = True
packages = find:
zip_safe = False
install_requires =
appdirs
platformdirs
pydantic
pyyaml
pywin32; sys_platform == "win32"
Expand All @@ -46,7 +46,6 @@ release =
twine
wheel
test =
appdirs-stubs
black
codespell
coverage
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_messages_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import time
from unittest.mock import MagicMock, call

import appdirs
import platformdirs
import pytest

from craft_cli import messages
Expand All @@ -43,10 +43,10 @@

@pytest.fixture
def test_log_dir(tmp_path, monkeypatch):
"""Provide a test log filepath, also fixing appdirs to use a temp dir."""
"""Provide a test log filepath, also fixing platformdirs to use a temp dir."""
dirpath = tmp_path / "testlogdir"
dirpath.mkdir()
monkeypatch.setattr(appdirs, "user_log_dir", lambda appname: dirpath / appname)
monkeypatch.setattr(platformdirs, "user_log_dir", lambda appname: dirpath / appname)
return dirpath


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

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