Skip to content

Commit

Permalink
refactor: extracted TimePeriod class to timeslot repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Nov 10, 2020
1 parent 2f8539b commit e4a2b53
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 352 deletions.
3 changes: 0 additions & 3 deletions aw_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

from . import __about__

# TODO timeperiod should be moved to a seperate library, has uses outside of ActivityWatch
from .timeperiod import TimePeriod

from . import decorators
from . import util

Expand Down
94 changes: 0 additions & 94 deletions aw_core/timeperiod.py

This file was deleted.

12 changes: 6 additions & 6 deletions aw_transform/filter_period_intersect.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
from copy import deepcopy

from aw_core import Event
from aw_core import TimePeriod
from timeslot import Timeslot

logger = logging.getLogger(__name__)


def _get_event_period(event: Event) -> TimePeriod:
def _get_event_period(event: Event) -> Timeslot:
start = event.timestamp
end = start + event.duration
return TimePeriod(start, end)
return Timeslot(start, end)


def _replace_event_period(event: Event, period: TimePeriod) -> Event:
def _replace_event_period(event: Event, period: Timeslot) -> Event:
e = deepcopy(event)
e.timestamp = period.start
e.duration = period.duration
Expand All @@ -23,8 +23,8 @@ def _replace_event_period(event: Event, period: TimePeriod) -> Event:

def _intersecting_eventpairs(
events1: List[Event], events2: List[Event]
) -> Iterable[Tuple[Event, Event, TimePeriod]]:
"""A generator that yields each overlapping pair of events from two eventlists along with a TimePeriod of the intersection"""
) -> Iterable[Tuple[Event, Event, Timeslot]]:
"""A generator that yields each overlapping pair of events from two eventlists along with a Timeslot of the intersection"""
events1.sort(key=lambda e: e.timestamp)
events2.sort(key=lambda e: e.timestamp)
e1_i = 0
Expand Down

0 comments on commit e4a2b53

Please sign in to comment.