Skip to content

Commit

Permalink
style: fixed lint warnings/formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Nov 8, 2023
1 parent 298b925 commit af51a20
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 18 deletions.
2 changes: 2 additions & 0 deletions src/quantifiedme/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .config import load_config

__all__ = ["load_config"]
23 changes: 10 additions & 13 deletions src/quantifiedme/build_dashboard.py
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -16,15 +17,15 @@

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()


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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -225,17 +226,13 @@ def build(what=None):


def _parse_args():
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--clear", action="store_true")
parser.add_argument("--what")
return parser.parse_args()


def main():
import shutil

args = _parse_args()
if args.clear:
shutil.rmtree(aw_research_dir / ".cache/joblib", ignore_errors=True)
Expand Down
2 changes: 1 addition & 1 deletion src/quantifiedme/derived/sleep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion src/quantifiedme/load/activitywatch_fake.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import random
from typing import Iterable
from collections.abc import Iterable
from datetime import datetime, timedelta

import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion src/quantifiedme/load/smartertime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/quantifiedme/load/toggl_.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
from typing import List
from datetime import datetime, timezone, timedelta

try:
Expand Down
2 changes: 1 addition & 1 deletion src/quantifiedme/timelineplot/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Tuple, TypeVar
from typing import TypeVar
from collections.abc import Iterable, Generator

T = TypeVar("T")
Expand Down

0 comments on commit af51a20

Please sign in to comment.