From: Shane Jaroch Date: Wed, 20 Jul 2022 20:57:35 +0000 (-0400) Subject: release-0.2.5 (#12) X-Git-Tag: v0.2.5 X-Git-Url: https://git.nutra.tk/v1?a=commitdiff_plain;h=refs%2Fpull%2F12%2Fhead;p=nutratech%2Fcli.git release-0.2.5 (#12) --- diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6742be6..5482a8c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,10 +1,10 @@ *********** - Changelog + ChangeLog *********** All notable changes to this project will be documented in this file. -The format is based on `Keep a Changelog `_, +The format is based on `Keep a Change Log `_, and this project adheres to `Semantic Versioning `_. @@ -15,8 +15,25 @@ and this project adheres to `Semantic Versioning +# NOTE: based on +# diff --git a/ntclient/services/analyze.py b/ntclient/services/analyze.py index 35c3b1b..994ec0c 100755 --- a/ntclient/services/analyze.py +++ b/ntclient/services/analyze.py @@ -71,8 +71,8 @@ def foods_analyze(food_ids: set, grams: int = 0) -> tuple: ################################################################################ servings_rows = [] nutrients_rows = [] - for food_id, food_des_tuple in analyses.items(): - food_name = food_des_tuple[2] + for food_id, nut_val_tuples in analyses.items(): + food_name = food_des[food_id][2] print( "\n======================================\n" + "==> {0} ({1})\n".format(food_name, food_id) @@ -105,7 +105,7 @@ def foods_analyze(food_ids: set, grams: int = 0) -> tuple: ################################################################################ headers = ["id", "nutrient", "rda", "amount", "units"] nutrient_rows = [] - for nutrient_id, amount in food_des_tuple: + for nutrient_id, amount in nut_val_tuples: # Skip zero values if not amount: continue diff --git a/ntclient/utils/__init__.py b/ntclient/utils/__init__.py index 12c5797..0a03c1b 100644 --- a/ntclient/utils/__init__.py +++ b/ntclient/utils/__init__.py @@ -11,12 +11,12 @@ THRESH_WARN = 0.7 COLOR_WARN = Fore.YELLOW THRESH_CRIT = 0.4 -COLOR_CRIT = Fore.RED +COLOR_CRIT = Style.DIM + Fore.RED THRESH_OVER = 1.9 COLOR_OVER = Style.DIM + Fore.MAGENTA -COLOR_DEFAULT = Style.BRIGHT + Fore.CYAN +COLOR_DEFAULT = Fore.CYAN ################################################################################ # Nutrient IDs diff --git a/requirements-test-win_xp-ubu1604.txt b/requirements-test-win_xp-ubu1604.txt index 0789c2f..39fde64 100644 --- a/requirements-test-win_xp-ubu1604.txt +++ b/requirements-test-win_xp-ubu1604.txt @@ -1,4 +1,3 @@ # Don't update these, they are the last supported versions on winXP, Ubuntu 16.04 & Python 3.4 -# coverage 5.5 technically works, but not for Travis CI -coverage>=4.5.4,<=5.5 +coverage==5.5 pytest==3.2.5 diff --git a/setup.cfg b/setup.cfg index 04fe26d..960849d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,10 +20,9 @@ per-file-ignores = # Allow unused imports in __init__.py files __init__.py:F401 -max-line-length = 100 +max-line-length = 88 ignore = - E501, # line-length (currently handled by pycodestyle) W503, # line break before binary operator diff --git a/setup.py b/setup.py index 845829c..ca2ef8e 100644 --- a/setup.py +++ b/setup.py @@ -50,7 +50,7 @@ with open("README.rst", encoding="utf-8") as file: with open("requirements.txt", encoding="utf-8") as file: REQUIREMENTS = file.read().split() -if PLATFORM_SYSTEM != "Windows": +if PLATFORM_SYSTEM != "Windows" or int(os.getenv("NUTRA_OS_FORCE_OPT_REQS", str(0))): # python-Levenshtein builds natively on Unix; Windows needs vcvarsall.bat or vc++10 with open("requirements-optional.txt", encoding="utf-8") as file: optional_reqs = file.read().split() diff --git a/tests/test_cli.py b/tests/test_cli.py index 6c6b129..fa0583d 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -53,10 +53,10 @@ def test_100_usda_sql_funcs(): result = usda_funcs.sql_nutrients_details() assert len(result[1]) == 186 - result = usda_funcs.sql_servings([9050, 9052]) + result = usda_funcs.sql_servings({9050, 9052}) assert len(result) == 3 - result = usda_funcs.sql_analyze_foods([23567, 23293]) + result = usda_funcs.sql_analyze_foods({23567, 23293}) assert len(result) == 188 result = usda_funcs.sql_sort_foods(789) @@ -76,9 +76,9 @@ def test_200_nt_sql_funcs(): assert version == __db_target_nt__ next_index = sql_nt_next_index("bf_eq") - assert next_index + assert next_index > 0 - # TODO: add more tests, it used to poll biometrics + # TODO: add more tests; we used to comb over biometrics here def test_300_argparser_debug_no_paging(): @@ -197,7 +197,7 @@ def test_600_sql_integrity_error__service_wip(): """Provokes IntegrityError in nt.sqlite3""" # TODO: replace with non-biometric test - # from ntclient.services import biometrics # pylint: disable=import-outside-toplevel + # from ntclient.services import biometrics # pylint: disable=import-outside-toplevel # # args = arg_parser.parse_args(args=["-d", "bio", "log", "add", "12,12"]) # biometrics.input = ( @@ -261,10 +261,12 @@ def test_802_usda_downloads_fresh_if_missing_or_deleted(): """Ensure download of usda.sqlite3.tar.xz, if usda.sqlite3 is missing""" from ntclient.persistence.sql import usda # pylint: disable=import-outside-toplevel - # TODO: similar for nt.sqlite3? Define development standards.. rebuilding, deleting, preserving + # TODO: similar for nt.sqlite3? + # Define development standards.. rebuilding, deleting, preserving # remove whole `.nutra` in a special test? try: - # TODO: export USDA_DB_PATH at package level, don't pepper os.path.join() throughout code? + # TODO: export USDA_DB_PATH at package level, + # don't pepper os.path.join() throughout code? usda_path = os.path.join(NUTRA_HOME, USDA_DB_NAME) os.remove(usda_path) except (FileNotFoundError, PermissionError) as err: @@ -285,7 +287,7 @@ def test_802_usda_downloads_fresh_if_missing_or_deleted(): def test_900_nut_rda_bar(): """Verifies colored/visual output is correctly generated""" - analysis = usda_funcs.sql_analyze_foods(food_ids=[1001]) + analysis = usda_funcs.sql_analyze_foods(food_ids={1001}) nutrients = usda_funcs.sql_nutrients_overview() output = nutprogbar.nutprogbar( food_amts={1001: 100}, food_analyses=analysis, nutrients=nutrients