13 lines
382 B
Python
13 lines
382 B
Python
|
|
import re
|
||
|
|
from datetime import timedelta
|
||
|
|
|
||
|
|
from model.TimeSlot import TimeSlot
|
||
|
|
|
||
|
|
|
||
|
|
def accumulate_duration(timeslots: list[TimeSlot]) -> timedelta:
|
||
|
|
return sum([ts.duration() for ts in timeslots], start=timedelta(0))
|
||
|
|
|
||
|
|
def filter(timeslots: list[TimeSlot], query: str) -> list[TimeSlot]:
|
||
|
|
pattern = re.compile(query)
|
||
|
|
return [ts for ts in timeslots if pattern.search(ts.name)]
|