Skip to content

Commit

Permalink
GH-89: Fiddle around with paths
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-ueding committed Feb 3, 2024
1 parent 4cb1690 commit e77cfe7
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions geo_activity_playground/core/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,31 @@
import typing


def make_path(path) -> typing.Callable[[], pathlib.Path]:
def dir_wrapper(
dir_func: typing.Callable[[], pathlib.Path]
) -> typing.Callable[[], pathlib.Path]:
@functools.wraps(dir_func)
@functools.cache
def path_creator() -> pathlib.Path:
def wrapper() -> pathlib.Path:
path = dir_func()
path.mkdir(exist_ok=True, parents=True)
return path

return path_creator
return wrapper


cache_dir = make_path(pathlib.Path("Cache"))
activity_timeseries_dir = lambda: make_path(cache_dir() / "Activity Timeseries")
@dir_wrapper
def cache_dir() -> pathlib.Path:
return pathlib.Path("Cache")

activities_path = lambda: cache_dir() / "activities.parquet"

@dir_wrapper
def activity_timeseries_dir() -> pathlib.Path:
return cache_dir() / "Activity Timeseries"


def activities_path() -> pathlib.Path:
return cache_dir() / "activities.parquet"


def activity_timeseries_path(activity_id: int) -> pathlib.Path:
Expand Down

0 comments on commit e77cfe7

Please sign in to comment.