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

Change user_log_dir to point to user_state_dir on Linux per the XDG spec #108

Merged
merged 4 commits into from Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/platformdirs/unix.py
Expand Up @@ -107,9 +107,9 @@ def user_state_dir(self) -> str:
@property
def user_log_dir(self) -> str:
"""
:return: log directory tied to the user, same as `user_data_dir` if not opinionated else ``log`` in it
:return: log directory tied to the user, same as `user_state_dir` if not opinionated else ``log`` in it
"""
path = self.user_cache_dir
path = self.user_state_dir
if self.opinion:
path = os.path.join(path, "log")
return path
Expand Down
6 changes: 6 additions & 0 deletions tests/test_comp_with_appdirs.py
Expand Up @@ -62,6 +62,12 @@ def test_compatibility(params: dict[str, Any], func: str) -> None:
}
if func in msg: # pragma: no cover
pytest.skip(f"`appdirs.{func}` {msg[func]} on macOS") # pragma: no cover
if sys.platform == "linux":
lordwelch marked this conversation as resolved.
Show resolved Hide resolved
msg = { # pragma: no cover
"user_log_dir": "Uses XDG_STATE_DIR instead of appdirs.user_data_dir per the XDG spec",
}
if func in msg: # pragma: no cover
pytest.skip(f"`appdirs.{func}` {msg[func]} on Linux") # pragma: no cover

new = getattr(platformdirs, func)(*params)
old = getattr(appdirs, func)(*params)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_unix.py
Expand Up @@ -59,7 +59,7 @@ def _func_to_path(func: str) -> XDGVariable | None:
"site_config_dir": XDGVariable("XDG_CONFIG_DIRS", "/etc/xdg"),
"user_cache_dir": XDGVariable("XDG_CACHE_HOME", "~/.cache"),
"user_state_dir": XDGVariable("XDG_STATE_HOME", "~/.local/state"),
"user_log_dir": XDGVariable("XDG_CACHE_HOME", "~/.cache"),
"user_log_dir": XDGVariable("XDG_STATE_HOME", "~/.local/state"),
"user_runtime_dir": XDGVariable("XDG_RUNTIME_DIR", "/run/user/1234"),
}
return mapping.get(func)
Expand Down