Skip to content

Commit

Permalink
fix: fixed typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Nov 22, 2021
1 parent f45d423 commit 9454222
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 34 deletions.
53 changes: 31 additions & 22 deletions aw_client/classes.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,54 @@
# Default classes
# Taken from default classes in aw-webui
default_classes = [
[["Work"], {"type": "regex", "regex": "Google Docs|libreoffice|ReText"}],
[
"""
Default classes
Taken from default classes in aw-webui
"""

from typing import List, Dict, Any, Tuple

CategoryId = List[str]
CategorySpec = Dict[str, Any]

default_classes: List[Tuple[CategoryId, CategorySpec]] = [
(["Work"], {"type": "regex", "regex": "Google Docs|libreoffice|ReText"}),
(
["Work", "Programming"],
{
"type": "regex",
"regex": "GitHub|Stack Overflow|BitBucket|Gitlab|vim|Spyder|kate|Ghidra|Scite",
},
],
[
),
(
["Work", "Programming", "ActivityWatch"],
{"type": "regex", "regex": "ActivityWatch|aw-", "ignore_case": True},
],
[["Work", "Image"], {"type": "regex", "regex": "Gimp|Inkscape"}],
[["Work", "Video"], {"type": "regex", "regex": "Kdenlive"}],
[["Work", "Audio"], {"type": "regex", "regex": "Audacity"}],
[["Work", "3D"], {"type": "regex", "regex": "Blender"}],
[["Media", "Games"], {"type": "regex", "regex": "Minecraft|RimWorld"}],
[["Media", "Video"], {"type": "regex", "regex": "YouTube|Plex|VLC"}],
[
),
(["Work", "Image"], {"type": "regex", "regex": "Gimp|Inkscape"}),
(["Work", "Video"], {"type": "regex", "regex": "Kdenlive"}),
(["Work", "Audio"], {"type": "regex", "regex": "Audacity"}),
(["Work", "3D"], {"type": "regex", "regex": "Blender"}),
(["Media", "Games"], {"type": "regex", "regex": "Minecraft|RimWorld"}),
(["Media", "Video"], {"type": "regex", "regex": "YouTube|Plex|VLC"}),
(
["Media", "Social Media"],
{
"type": "regex",
"regex": "reddit|Facebook|Twitter|Instagram|devRant",
"ignore_case": True,
},
],
[
),
(
["Media", "Music"],
{"type": "regex", "regex": "Spotify|Deezer", "ignore_case": True},
],
[
),
(
["Comms", "IM"],
{
"type": "regex",
"regex": "Messenger|Telegram|Signal|WhatsApp|Rambox|Slack|Riot|Discord|Nheko",
},
],
[
),
(
["Comms", "Email"],
{"type": "regex", "regex": "Gmail|Thunderbird|mutt|alpine"},
],
),
]
17 changes: 9 additions & 8 deletions aw_client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
import click
from tabulate import tabulate

import aw_client
from aw_client import queries
from aw_core import Event

import aw_client
from . import queries
from .classes import default_classes


now = datetime.now(timezone.utc)
td1day = timedelta(days=1)
td1yr = timedelta(days=365)
Expand Down Expand Up @@ -167,11 +170,9 @@ def report(
bid_browsers: List[str] = []

logger.info("Using default classes")
from .classes import default_classes

classes: List[dict] = default_classes
classes = default_classes

filter_classes: List[str] = []
filter_classes: List[List[str]] = []
filter_afk: bool = True
include_audible: bool = True

Expand Down Expand Up @@ -259,8 +260,8 @@ def canonical(
stop = stop.astimezone()

bid_browsers: List[str] = []
classes: List[dict] = []
filter_classes: List[str] = []
classes = default_classes
filter_classes: List[List[str]] = []
filter_afk: bool = True
include_audible: bool = True

Expand Down
8 changes: 4 additions & 4 deletions aw_client/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def default(self, o):
@dataclass
class QueryParams:
bid_browsers: List[str]
classes: List[dict]
filter_classes: List[str]
classes: List[Tuple[List[str], dict]]
filter_classes: List[List[str]]
filter_afk: bool
include_audible: bool

Expand Down Expand Up @@ -202,10 +202,10 @@ def fullDesktopQuery(
windowbucket: str,
afkbucket: str,
filterAFK: bool,
classes: List[dict],
classes: List[Tuple[List[str], dict]],
filterCategories: List[List[str]],
include_audible: bool,
) -> List[str]:
) -> str:
# Escape `"`
browserbuckets = [escape_doublequote(bucket) for bucket in browserbuckets]
windowbucket = escape_doublequote(windowbucket)
Expand Down

0 comments on commit 9454222

Please sign in to comment.