Add informal Parser interface
Added first informal parser interface, only requiring a method to parse events and one to parse trackers. Theoretically we only *require* a method to parse events since, through their contained activities, they would also come with trackers. But this would 1) be much more opaque and a lot of work to then extract the trackers again and 2) leave out trackers which do not yet have any activities associated with them (i.e. trackers never once accomplished). We can still turn the informal parser into a formal interface if need arises: https://realpython.com/python-interface/
This commit is contained in:
parent
031145db01
commit
2bbb594d62
2 changed files with 17 additions and 1 deletions
|
@ -47,7 +47,7 @@ class Event:
|
||||||
id: str
|
id: str
|
||||||
start: int
|
start: int
|
||||||
end: int
|
end: int
|
||||||
text: str
|
text: str = ""
|
||||||
activities: list[Activity] = field(default_factory=lambda: [])
|
activities: list[Activity] = field(default_factory=lambda: [])
|
||||||
score: int = 0
|
score: int = 0
|
||||||
lat: float = 0.0
|
lat: float = 0.0
|
||||||
|
|
16
src/habitmove/parser.py
Normal file
16
src/habitmove/parser.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
from habitmove.nomiedata import Event, Tracker
|
||||||
|
|
||||||
|
|
||||||
|
class Parser:
|
||||||
|
def __init__(self, path: str, filename: str) -> None:
|
||||||
|
"""Load in a data set"""
|
||||||
|
self.path = path
|
||||||
|
self.filename = filename
|
||||||
|
|
||||||
|
def extract_trackers(self) -> list[Tracker]:
|
||||||
|
"""Extract trackers from the data set"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def extract_events(self) -> list[Event]:
|
||||||
|
"""Extract events from the data set"""
|
||||||
|
raise NotImplementedError
|
Loading…
Reference in a new issue