Skip to content

Commit

Permalink
fix: migrate to platformdirs from deprecated appdirs (#122)
Browse files Browse the repository at this point in the history
* Migrate to `platformdirs`

* Formatting
  • Loading branch information
BelKed committed Jul 6, 2023
1 parent 22deef5 commit ebdf2dd
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 158 deletions.
10 changes: 5 additions & 5 deletions aw_core/dirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from functools import wraps
from typing import Optional, Callable

import appdirs
import platformdirs

GetDirFunc = Callable[[Optional[str]], str]

Expand All @@ -24,23 +24,23 @@ def wrapper(subpath: Optional[str] = None) -> str:

@_ensure_returned_path_exists
def get_data_dir(module_name: Optional[str] = None) -> str:
data_dir = appdirs.user_data_dir("activitywatch")
data_dir = platformdirs.user_data_dir("activitywatch")
return os.path.join(data_dir, module_name) if module_name else data_dir


@_ensure_returned_path_exists
def get_cache_dir(module_name: Optional[str] = None) -> str:
cache_dir = appdirs.user_cache_dir("activitywatch")
cache_dir = platformdirs.user_cache_dir("activitywatch")
return os.path.join(cache_dir, module_name) if module_name else cache_dir


@_ensure_returned_path_exists
def get_config_dir(module_name: Optional[str] = None) -> str:
config_dir = appdirs.user_config_dir("activitywatch")
config_dir = platformdirs.user_config_dir("activitywatch")
return os.path.join(config_dir, module_name) if module_name else config_dir


@_ensure_returned_path_exists
def get_log_dir(module_name: Optional[str] = None) -> str: # pragma: no cover
log_dir = appdirs.user_log_dir("activitywatch")
log_dir = platformdirs.user_log_dir("activitywatch")
return os.path.join(log_dir, module_name) if module_name else log_dir
1 change: 0 additions & 1 deletion aw_datastore/storages/peewee.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@


def auto_migrate(path: str) -> None:

db = SqliteExtDatabase(path)
migrator = SqliteMigrator(db)

Expand Down

0 comments on commit ebdf2dd

Please sign in to comment.