move data files out of repo

This commit is contained in:
olari
2021-06-19 11:50:19 +03:00
parent f4c4407ebc
commit 195c430797
6 changed files with 25 additions and 2254 deletions

View File

@@ -8,9 +8,9 @@ def format_timestamp(timestamp):
return datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S')
def parse_foods_file():
path = Path.home() / 'projects' / 'open-journal' / 'foods'
path = Path.home() / 'workspace' / 'journal' / 'foods'
text = path.read_text()
foods, recipes_str = text.split('---')
foods_str, recipes_str = text.split('---')
def parse_macro(macro):
if macro == '...':
@@ -22,7 +22,7 @@ def parse_foods_file():
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')]
for macros in [food.split('\n') for food in foods_str.strip().split('\n\n')]
}
def combine_values(fst, snd):
@@ -100,7 +100,8 @@ def evaluate_food_entry(foods, recipes, value, name):
food = {k: v*(value/100.0) for k,v in foods[name].items()}
else:
breakpoint()
print(f'ERROR: Invalid diet entry: {content}')
print(f'ERROR: Invalid diet entry: {name}')
assert False
return food