From: Shane Jaroch Date: Sun, 25 Feb 2024 18:21:54 +0000 (-0500) Subject: wip X-Git-Tag: v0.2.8.dev0~20 X-Git-Url: https://git.nutra.tk/v1?a=commitdiff_plain;h=1bf5de3c7c99360e99bae450f354bcb70b3f07f3;p=nutratech%2Fcli.git wip --- diff --git a/ntclient/core/nutprogbar.py b/ntclient/core/nutprogbar.py index ad6c337..f656886 100644 --- a/ntclient/core/nutprogbar.py +++ b/ntclient/core/nutprogbar.py @@ -15,6 +15,8 @@ def nutprogbar( # TODO: get RDA values from nt DB, tree node nested organization print(nut) + # for _food_analysis in food_analyses: + # print(_food_analysis) food_analyses_dict = { x[0]: {y[1]: y[2] for y in food_analyses if y[0] == x[0]} for x in food_analyses } diff --git a/ntclient/services/analyze.py b/ntclient/services/analyze.py index 28c0b63..bdb4aff 100644 --- a/ntclient/services/analyze.py +++ b/ntclient/services/analyze.py @@ -108,8 +108,8 @@ def foods_analyze(food_ids: set, grams: float = 100) -> tuple: print_header("NUTRITION") headers = ["id", "nutrient", "rda %", "amount", "units"] nutrient_rows = [] + # TODO: skip small values (<1% RDA), report as color bar if RDA is available for nutrient_id, amount in nut_val_tuples: - # TODO: skip small values (<1% RDA), report as color bar if RDA is available # Skip zero values if not amount: continue @@ -129,16 +129,18 @@ def foods_analyze(food_ids: set, grams: float = 100) -> tuple: nutrient_rows.append(row) # Print view - try: - # TODO: nested, color-coded tree view - # TODO: either make this function singular, or handle plural logic here - _food_id = list(food_ids)[0] - nutprogbar(_food_id, analyses[_food_id], nutrients) - except NameError as exception: - print(repr(exception)) - # exit(0) + # TODO: nested, color-coded tree view + # TODO: either make this function singular, or handle plural logic here + _food_id = list(food_ids)[0] + nutprogbar( + {_food_id: grams}, + [(_food_id, x[0], x[1]) for x in analyses[_food_id]], + nutrients, + ) + # BEGIN: deprecated code table = tabulate(nutrient_rows, headers=headers, tablefmt="presto") print(table) + # END: deprecated code nutrients_rows.append(nutrient_rows) return 0, nutrients_rows, servings_rows @@ -148,9 +150,13 @@ def foods_analyze(food_ids: set, grams: float = 100) -> tuple: # Day ############################################################################## def day_analyze(day_csv_paths: Sequence[str], rda_csv_path: str = str()) -> tuple: - """Analyze a day optionally with custom RDAs, - e.g. nutra day ~/.nutra/rocky.csv -r ~/.nutra/dog-rdas-18lbs.csv - TODO: Should be a subset of foods_analyze + """Analyze a day optionally with custom RDAs, examples: + + ./nutra day tests/resources/day/human-test.csv + + nutra day ~/.nutra/rocky.csv -r ~/.nutra/dog-rdas-18lbs.csv + + TODO: Should be a subset of foods_analyze (encapsulate/abstract/reuse code) """ # Get user RDAs from CSV file, if supplied