my.body.blood: use same file
overall I guess this module is highly specific to me anyway, so gonna be hard to make it generic...
This commit is contained in:
parent
5b501d1562
commit
3a1e21635a
2 changed files with 9 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
||||||
"""
|
"""
|
||||||
Blood tracking
|
Blood tracking (manual org-mode entries)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
@ -47,9 +47,11 @@ def try_float(s: str) -> Optional[float]:
|
||||||
return None
|
return None
|
||||||
return float(x)
|
return float(x)
|
||||||
|
|
||||||
|
|
||||||
def glucose_ketones_data() -> Iterable[Result]:
|
def glucose_ketones_data() -> Iterable[Result]:
|
||||||
o = orgparse.load(config.blood_log)
|
o = orgparse.load(config.blood_log)
|
||||||
tbl = one_table(o)
|
[n] = [x for x in o if x.heading == 'glucose/ketones']
|
||||||
|
tbl = one_table(n)
|
||||||
# todo some sort of sql-like interface for org tables might be ideal?
|
# todo some sort of sql-like interface for org tables might be ideal?
|
||||||
for l in tbl.as_dicts:
|
for l in tbl.as_dicts:
|
||||||
kets = l['ket']
|
kets = l['ket']
|
||||||
|
@ -74,8 +76,9 @@ def glucose_ketones_data() -> Iterable[Result]:
|
||||||
|
|
||||||
|
|
||||||
def blood_tests_data() -> Iterable[Result]:
|
def blood_tests_data() -> Iterable[Result]:
|
||||||
o = orgparse.load(config.blood_tests_log)
|
o = orgparse.load(config.blood_log)
|
||||||
tbl = one_table(o)
|
[n] = [x for x in o if x.heading == 'blood tests']
|
||||||
|
tbl = one_table(n)
|
||||||
for d in tbl.as_dicts:
|
for d in tbl.as_dicts:
|
||||||
try:
|
try:
|
||||||
dt = parse_org_datetime(d['datetime'])
|
dt = parse_org_datetime(d['datetime'])
|
||||||
|
|
|
@ -19,6 +19,8 @@ def parse_org_datetime(s: str) -> datetime:
|
||||||
raise RuntimeError(f"Bad datetime string {s}")
|
raise RuntimeError(f"Bad datetime string {s}")
|
||||||
|
|
||||||
|
|
||||||
|
# TODO I guess want to borrow inspiration from bs4? element type <-> tag; and similar logic for find_one, find_all
|
||||||
|
|
||||||
from orgparse import OrgNode
|
from orgparse import OrgNode
|
||||||
from typing import Iterable, TypeVar, Callable
|
from typing import Iterable, TypeVar, Callable
|
||||||
V = TypeVar('V')
|
V = TypeVar('V')
|
||||||
|
|
Loading…
Add table
Reference in a new issue