diff --git a/src/quantifiedme/__init__.py b/src/quantifiedme/__init__.py index c49bb97..fef643b 100644 --- a/src/quantifiedme/__init__.py +++ b/src/quantifiedme/__init__.py @@ -1 +1,3 @@ from .config import load_config + +__all__ = ["load_config"] diff --git a/src/quantifiedme/build_dashboard.py b/src/quantifiedme/build_dashboard.py index a1a8388..9514e73 100644 --- a/src/quantifiedme/build_dashboard.py +++ b/src/quantifiedme/build_dashboard.py @@ -1,10 +1,11 @@ +import argparse +import glob +import json import os +import shutil import subprocess -import json -from pathlib import Path - from datetime import datetime, timedelta - +from pathlib import Path cache_dir = Path(".cache").absolute() aw_research_dir = Path("aw-research").absolute() @@ -16,7 +17,7 @@ def _read_qslang_cats(): with open("./data/substance-categories.txt") as f: - return [l.strip() for l in f.readlines()] + return [line.strip() for line in f.readlines()] qslang_cats = _read_qslang_cats() @@ -24,7 +25,7 @@ def _read_qslang_cats(): def _read_people_colocate(): with open("./data/people-colocate.txt") as f: - return [l.strip() for l in f.readlines()] + return [line.strip() for line in f.readlines()] people_colocate = _read_people_colocate() @@ -66,7 +67,9 @@ def _build_category_sunburst(): print(str(p.stderr, "utf-8")) lines = str(p.stdout, "utf-8").split("\n") duration = next( - l.strip().lstrip("Duration:").strip() for l in lines if "Duration" in l + line.strip().lstrip("Duration:").strip() + for line in lines + if "Duration" in line ) with open(f".cache/{name}-sunburst.json", "w") as f: json.dump({"duration": duration}, f) @@ -109,8 +112,6 @@ def _build_location_plot(): def _read_metadata(): - import glob - metadata = {} for filepath in glob.glob(".cache/*.json"): name = filepath.split("/")[-1].rstrip(".json") @@ -225,8 +226,6 @@ def build(what=None): def _parse_args(): - import argparse - parser = argparse.ArgumentParser() parser.add_argument("--clear", action="store_true") parser.add_argument("--what") @@ -234,8 +233,6 @@ def _parse_args(): def main(): - import shutil - args = _parse_args() if args.clear: shutil.rmtree(aw_research_dir / ".cache/joblib", ignore_errors=True) diff --git a/src/quantifiedme/derived/sleep.py b/src/quantifiedme/derived/sleep.py index ebbc2dd..b0d4bb3 100644 --- a/src/quantifiedme/derived/sleep.py +++ b/src/quantifiedme/derived/sleep.py @@ -64,7 +64,7 @@ def load_sleep_df(ignore: list[str] = [], aggregate=True) -> pd.DataFrame: # perform some aggregations if aggregate: keys: list[str] = list( - set(col.split("_")[0] for col in df.columns) & {"duration", "score"} + {col.split("_")[0] for col in df.columns} & {"duration", "score"} ) for key in keys: subkeys = df.columns[df.columns.str.startswith(key)] diff --git a/src/quantifiedme/load/activitywatch_fake.py b/src/quantifiedme/load/activitywatch_fake.py index ffb4169..80d9ccc 100644 --- a/src/quantifiedme/load/activitywatch_fake.py +++ b/src/quantifiedme/load/activitywatch_fake.py @@ -1,5 +1,5 @@ import random -from typing import Iterable +from collections.abc import Iterable from datetime import datetime, timedelta import numpy as np diff --git a/src/quantifiedme/load/smartertime.py b/src/quantifiedme/load/smartertime.py index 9d6e3b0..11fa0e8 100644 --- a/src/quantifiedme/load/smartertime.py +++ b/src/quantifiedme/load/smartertime.py @@ -65,7 +65,7 @@ def _load_smartertime_events(since: datetime, filepath) -> list[Event]: def read_csv_to_events(filepath): events = [] - with open(filepath, "r") as f: + with open(filepath) as f: c = csv.DictReader(f) for r in c: # print(r) diff --git a/src/quantifiedme/load/toggl_.py b/src/quantifiedme/load/toggl_.py index 6a3f2ab..32899ca 100644 --- a/src/quantifiedme/load/toggl_.py +++ b/src/quantifiedme/load/toggl_.py @@ -1,5 +1,4 @@ import logging -from typing import List from datetime import datetime, timezone, timedelta try: diff --git a/src/quantifiedme/timelineplot/util.py b/src/quantifiedme/timelineplot/util.py index 27d0f27..3c89429 100644 --- a/src/quantifiedme/timelineplot/util.py +++ b/src/quantifiedme/timelineplot/util.py @@ -1,4 +1,4 @@ -from typing import Tuple, TypeVar +from typing import TypeVar from collections.abc import Iterable, Generator T = TypeVar("T")