my.jawbone: minor cleanup & refactoring, proper error propagation

This commit is contained in:
Dima Gerasimov 2020-09-10 20:52:33 +01:00 committed by karlicoss
parent 99e50f0afe
commit 63b848087d
7 changed files with 108 additions and 86 deletions

View file

@ -53,11 +53,10 @@ def from_orgmode() -> Iterator[Result]:
)
def dataframe():
def make_dataframe(data: Iterator[Result]):
import pandas as pd # type: ignore
entries = from_orgmode()
def it():
for e in from_orgmode():
for e in data:
if isinstance(e, Exception):
dt = extract_error_datetime(e)
yield {
@ -75,6 +74,11 @@ def dataframe():
df.index = pd.to_datetime(df.index, utc=True)
return df
def dataframe():
entries = from_orgmode()
return make_dataframe(entries)
# TODO move to a submodule? e.g. my.body.weight.orgmode?
# so there could be more sources
# not sure about my.body thing though