update
This commit is contained in:
72
foods
72
foods
@@ -1,4 +1,52 @@
|
||||
|
||||
Cereal
|
||||
Energy 373kcal
|
||||
Fat 1.4g
|
||||
SaturatedFat 0.4g
|
||||
Carbs 78g
|
||||
Sugar 13.9g
|
||||
Fiber 7.1g
|
||||
Protein 8.5g
|
||||
Salt 0.39g
|
||||
|
||||
SadonkorjuuPuuro
|
||||
Energy 385kcal
|
||||
Fat 11g
|
||||
SaturatedFat 1.7g
|
||||
Carbs 51g
|
||||
Sugar 1.1g
|
||||
Fiber 11g
|
||||
Protein 14g
|
||||
|
||||
DaimCake
|
||||
Energy 446kcal
|
||||
Fat 28g
|
||||
SaturatedFat 9.3g
|
||||
Carbs 39g
|
||||
Sugar 37g
|
||||
Protein 9.1g
|
||||
Salt 0.35g
|
||||
|
||||
KaneliKierre
|
||||
Energy 350kcal
|
||||
Fat 14g
|
||||
SaturatedFat 5.6g
|
||||
Carbs 55g
|
||||
Sugar 20g
|
||||
Fiber 2g
|
||||
Protein 6g
|
||||
Salt 0.7g
|
||||
|
||||
Munkki
|
||||
Energy 395kcal
|
||||
Fat 23g
|
||||
SaturatedFat 10g
|
||||
Carbs 39g
|
||||
Sugar 9.6g
|
||||
Fiber 2.7g
|
||||
Protein 5.8g
|
||||
Salt 0.5g
|
||||
|
||||
ProteinRakha
|
||||
Energy 67kcal
|
||||
Fat 0.2g
|
||||
@@ -693,6 +741,10 @@ Milk 180g
|
||||
Potato 1000g
|
||||
TOTAL 1300g
|
||||
|
||||
MashedPotato3
|
||||
Potato 1050g
|
||||
Milk 350g
|
||||
|
||||
Blov
|
||||
BrownRice 600g
|
||||
Ketchup 250g
|
||||
@@ -791,6 +843,12 @@ Milk 240g
|
||||
Egg 65g
|
||||
GrahamFlour 60g
|
||||
|
||||
VegeKotlet2
|
||||
HarkisRouheseos 200g
|
||||
Milk 450g
|
||||
WholeGrainBread 50g
|
||||
Flour 90g
|
||||
|
||||
RoastedVeggies2
|
||||
Broccoli 300g
|
||||
Oil 70g
|
||||
@@ -804,9 +862,23 @@ PeasCornPepper 200g
|
||||
Ketchup 100g
|
||||
TOTAL 760g
|
||||
|
||||
BeanitHarkisVeggies2
|
||||
Oil 40g
|
||||
BeanitHarkis 250g
|
||||
PeasCornPepper 220g
|
||||
Ketchup 100g
|
||||
TOTAL 740g
|
||||
|
||||
Pancake
|
||||
SkimMilk 430g
|
||||
Water 300g
|
||||
Oil 30g
|
||||
Flour 430g
|
||||
Sugar 20g
|
||||
|
||||
SadonkorjuuPuuroBoiled
|
||||
SadonkorjuuPuuro 160g
|
||||
SkimMilk 100g
|
||||
Margarine 20g
|
||||
TOTAL 788
|
||||
|
||||
|
||||
36
progress.py
36
progress.py
@@ -7,27 +7,11 @@ from common import parse_timestamp
|
||||
|
||||
content = open(sys.argv[1]).read().strip()
|
||||
|
||||
"""
|
||||
|
||||
* Total hours
|
||||
* Hours today
|
||||
* Hours this week
|
||||
|
||||
* Percentage completed
|
||||
* Pages completed
|
||||
|
||||
* Estimated hours to completion
|
||||
* Estimated completion date
|
||||
|
||||
"""
|
||||
|
||||
lines = content.splitlines()
|
||||
i = 0
|
||||
current_chapter = ''
|
||||
result = defaultdict(float)
|
||||
|
||||
total_chapters = 0
|
||||
completed_chapters = 0
|
||||
completed_chapters = set()
|
||||
|
||||
today = datetime.now().replace(hour=0,minute=0,second=0,microsecond=0)
|
||||
this_week = today - timedelta(days=7)
|
||||
@@ -38,13 +22,17 @@ week_hours = 0.0
|
||||
|
||||
oldest_timestamp = datetime.now()
|
||||
|
||||
i = 0
|
||||
while i < len(lines):
|
||||
line = lines[i].strip()
|
||||
|
||||
if line.startswith('#'):
|
||||
current_chapter = line[line.find(' ')+1:]
|
||||
total_chapters += 1
|
||||
elif line.startswith('@start'):
|
||||
else:
|
||||
completed_chapters.add(current_chapter)
|
||||
|
||||
if line.startswith('@start'):
|
||||
start = parse_timestamp(line.removeprefix('@start '))
|
||||
|
||||
if start < oldest_timestamp:
|
||||
@@ -54,28 +42,18 @@ while i < len(lines):
|
||||
line = lines[i].strip()
|
||||
|
||||
end = parse_timestamp(line.removeprefix('@stop '))
|
||||
|
||||
delta = end - start
|
||||
|
||||
hours = delta.seconds / 60 / 60
|
||||
|
||||
result[current_chapter] += hours
|
||||
total_hours += hours
|
||||
|
||||
if start > this_week:
|
||||
week_hours += hours
|
||||
if start > today:
|
||||
day_hours += hours
|
||||
|
||||
elif line.startswith('@done'):
|
||||
completed_chapters += 1
|
||||
|
||||
|
||||
|
||||
i += 1
|
||||
|
||||
#from pprint import pprint
|
||||
#pprint(dict(result), sort_dicts=False)
|
||||
completed_chapters = len(completed_chapters)
|
||||
|
||||
num_days = (datetime.now() - oldest_timestamp).days or 1
|
||||
hours_per_day = total_hours / num_days
|
||||
|
||||
79
summary.py
79
summary.py
@@ -7,88 +7,19 @@ import string
|
||||
|
||||
import sys
|
||||
|
||||
def parse_foods_file():
|
||||
path = Path.home() / 'projects' / 'open-journal' / 'foods'
|
||||
text = path.read_text()
|
||||
foods, recipes = text.split('---')
|
||||
do_yesterday = len(sys.argv) > 1
|
||||
|
||||
def parse_macro(macro):
|
||||
if macro == '...':
|
||||
return ('INVALID', 0.0)
|
||||
|
||||
name, value = macro.split()
|
||||
value = float(value.removesuffix('g').removesuffix('kcal'))
|
||||
return (name, value)
|
||||
|
||||
foods = {
|
||||
macros[0]: dict(parse_macro(macro) for macro in macros[1:])
|
||||
for macros in [food.split('\n') for food in foods.strip().split('\n\n')]
|
||||
}
|
||||
|
||||
def combine_values(fst, snd):
|
||||
result = fst.copy()
|
||||
for k,v in snd.items():
|
||||
if k in fst:
|
||||
result[k] += v
|
||||
else:
|
||||
result[k] = v
|
||||
return result
|
||||
|
||||
def evaluate_ingredients(ingredients):
|
||||
result = {}
|
||||
|
||||
total_weight = 0.0
|
||||
for ingredient in ingredients:
|
||||
k,v = parse_macro(ingredient)
|
||||
if k == 'TOTAL':
|
||||
result[k] = v
|
||||
break
|
||||
else:
|
||||
total_weight += v
|
||||
|
||||
|
||||
food = foods[k]
|
||||
|
||||
for kk,vv in food.items():
|
||||
if kk not in result:
|
||||
result[kk] = 0.0
|
||||
|
||||
result[kk] += vv * (v/100.0)
|
||||
|
||||
if 'TOTAL' not in result:
|
||||
result['TOTAL'] = total_weight
|
||||
|
||||
return result
|
||||
|
||||
recipes = {
|
||||
ingredients[0]: evaluate_ingredients(ingredients[1:])
|
||||
for ingredients in [
|
||||
recipe.split('\n') for recipe in recipes.strip().split('\n\n')
|
||||
]
|
||||
}
|
||||
|
||||
def get_calories_from_macros(mm):
|
||||
calories = 0.0
|
||||
for k,v in mm.items():
|
||||
calories += v * {
|
||||
'Carbs': 4,
|
||||
'Fat': 9,
|
||||
'Protein': 4
|
||||
}.get(k, 0.0)
|
||||
return calories
|
||||
|
||||
#for k,v in foods.items():
|
||||
# print(round(v.get('Energy') - get_calories_from_macros(v)), k)
|
||||
|
||||
return foods, recipes
|
||||
from common import parse_foods_file
|
||||
|
||||
foods, recipes = parse_foods_file()
|
||||
|
||||
entry_re = re.compile(r'^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ', re.MULTILINE)
|
||||
diet_re = re.compile(r'@diet (\d+g) ([a-zA-Z]+)')
|
||||
|
||||
day_index = -2 if do_yesterday else -1
|
||||
|
||||
current_day = list(sorted((Path.home() / 'workspace' /
|
||||
'journal').glob('*.md')))[-1]
|
||||
'journal').glob('*.md')))[day_index]
|
||||
|
||||
header, *tmp = entry_re.split(current_day.read_text())
|
||||
entries = list(zip(tmp[::2], tmp[1::2]))
|
||||
|
||||
Reference in New Issue
Block a user