release-0.2.5 (#12) 12/head v0.2.5
authorShane Jaroch <chown_tee@proton.me>
Wed, 20 Jul 2022 20:57:35 +0000 (16:57 -0400)
committerShane Jaroch <chown_tee@proton.me>
Wed, 20 Jul 2022 23:28:47 +0000 (19:28 -0400)
CHANGELOG.rst
README.rst
ntclient/__init__.py
ntclient/core/nnr2.py
ntclient/services/analyze.py
ntclient/utils/__init__.py
requirements-test-win_xp-ubu1604.txt
setup.cfg
setup.py
tests/test_cli.py

index 6742be63b0027e78afb4d435e9da532873ac4b46..5482a8c4ac70b12df7bf8d2446c937a30d6c22b2 100644 (file)
@@ -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 <https://keepachangelog.com/en/1.1.0/>`_,
+The format is based on `Keep a Change Log <https://keepachangelog.com/en/1.1.0/>`_,
 and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_.
 
 
@@ -15,8 +15,25 @@ and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0
 Added
 ~~~~~
 
-- Basic functionality of ``import`` and ``export`` sub-commands
-- Automated CI/CD integration tests for ``Windows`` platform
+- Basic functionality of ``import`` and ``export`` sub-commands.
+
+
+
+[0.2.4] - 2022-07-20
+########################################################################
+
+Added
+~~~~~
+
+- Automated CI/CD integration tests for ``Windows`` platform and multiple
+  Python versions.
+- Enhanced linting, type checking, and true Python 3.4 compliance.
+
+Changed
+~~~~~~~
+
+- Specify version **range** for package dependencies, test old Linux / Python.
+- Clean up SQL drivers and Python functions. Use non-plural tables.
 
 
 
@@ -26,15 +43,15 @@ Added
 Added
 ~~~~~
 
-- ``[WIP]`` Download cache & checksum verification
+- ``[WIP]`` Download cache & checksum verification.
 - ``[DEVELOPMENT]`` Added ``Makefile`` with easy commands for ``init``,
-  ``lint``, ``test``, etc
-- ``n`` as a shorthand script for ``nutra``
+  ``lint``, ``test``, etc.
+- ``n`` as a shorthand script for ``nutra``.
 
 Changed
 ~~~~~~~
 
-- Rename to ``CHANGELOG.rst``
+- Rename to ``CHANGELOG.rst`` (from markdown ``*.md``).
 
 Fixed
 ~~~~~
@@ -56,23 +73,23 @@ Added
 ~~~~~
 
 - Limit search & sort results to top ``n`` results (e.g. top 10 or top 100)
-- Enhanced terminal sizing (buffer termination)
-- ``Pydoc`` ``PAGING`` flag via ``--no-pager`` command line arg
-  (with ``set_flags()`` method)
-- Check for appropriate ``ntsqlite`` database version
+- Enhanced terminal sizing (buffer termination).
+- ``Pydoc`` ``PAGING`` flag via ``--no-pager`` command line argument
+  (with ``set_flags()`` method).
+- Check for appropriate ``ntsqlite`` database version.
 - ``[DEVELOPMENT]`` Special ``file_or_dir_path`` and ``file_path``
-  custom type validators for ``argparse``
+  custom type validators for ``argparse``.
 - ``[DEVELOPMENT]`` Added special requirements files for
   (``test``, ``lint``, ``optional: Levenshtein``,
-  and ``win_xp-test`` [Python 3.4])
-- ``[DEVELOPMENT]`` Added ``CHANGELOG.md`` file
+  and ``win_xp-test`` [Python 3.4]).
+- ``[DEVELOPMENT]`` Added ``CHANGELOG.md`` file.
 
 Changed
 ~~~~~~~
 
-- Print ``exit_code`` in DEBUG mode (`--debug` flag/arg)
-- Moved ``subparsers`` module in ``ntclient.argparser`` to ``__init__``
-- Moved tests out of ``ntclient/`` and into ``tests/`` folder
+- Print ``exit_code`` in DEBUG mode (`--debug` flag/argument).
+- Moved ``subparsers`` module in ``ntclient.argparser`` to ``__init__``.
+- Moved tests out of ``ntclient/`` and into ``tests/`` folder.
 
 
 
@@ -82,20 +99,20 @@ Changed
 Added
 ~~~~~
 
-- Python 3.4 support (Windows XP and Ubuntu 16.04)
-- Debug flag (``--debug | -d``) for all commands
+- Python 3.4 support (Windows XP and Ubuntu 16.04).
+- Debug flag (``--debug | -d``) for all commands.
 
 Changed
 ~~~~~~~
 
-- Overall structure with main file and argparse methods
-- Use soft pip requirements ``~=`` instead of ``==``
-- ``DEFAULT`` and ``OVER`` colors
+- Overall structure with main file and ``argparse`` methods.
+- Use soft pip requirements ``~=`` instead of ``==``.
+- ``DEFAULT`` and ``OVER`` colors.
 
 Removed
 ~~~~~~~
 
-- ``guid`` columns from ``ntsqlite`` submodule
+- ``guid`` columns from ``ntsqlite`` submodule.
 
 
 
@@ -106,11 +123,11 @@ Added
 ~~~~~
 
 - SQLite support for ``usda`` and ``nt`` schemas
-  (removed API calls to remote server)
-- Preliminary support for ``recipe`` and ``bio`` subcommands
-- On-boarding process with ``init`` subcommand
-- Support for ``argcomplete`` on ``bash`` (Linux/macOS)
-- Tests
+  (removed API calls to remote server).
+- Preliminary support for ``recipe`` and ``bio`` sub-commands.
+- On-boarding process with ``init`` sub-command.
+- Support for ``argcomplete`` on ``bash`` (Linux/macOS).
+- Tests in the form of a sole ``test_cli.py`` file.
 
 
 
@@ -120,4 +137,4 @@ Added
 Added
 ~~~~~
 
-- Support for analysis of day CSV files
+- Support for analysis of "day" ``CSV`` files.
index 1615c2f2de0d8f706692753dc879828aba643f48..f449d57bec55574942fdbde95f9f586c064aca2c 100644 (file)
@@ -212,7 +212,7 @@ Commands
 ::
 
   usage: nutra [-h] [-v] [-d] [--no-pager]
-               {init,nt,search,sort,anl,day,recipe,bio} ...
+               {init,nt,search,sort,anl,day,recipe} ...
 
   optional arguments:
     -h, --help            show this help message and exit
@@ -221,7 +221,7 @@ Commands
     --no-pager            disable paging (print full output)
 
   nutra subcommands:
-    {init,nt,search,sort,anl,day,recipe,bio}
+    {init,nt,search,sort,anl,day,recipe}
       init                setup profiles, USDA and NT database
       nt                  list out nutrients and their info
       search              search foods by name, list overview info
index 30d9e38dd3adb8ebd2bb57b589820f690995ca22..fb9f38f5dcbbd0b55f381da88de67e9aa98776ba 100755 (executable)
@@ -35,7 +35,7 @@ from ntclient.ntsqlite.sql import NT_DB_NAME
 
 # Package info
 __title__ = "nutra"
-__version__ = "0.2.5.dev1"
+__version__ = "0.2.5"
 __author__ = "Shane Jaroch"
 __email__ = "chown_tee@proton.me"
 __license__ = "GPL v3"
index dd94458510c34bad8aba356b4d48ec6e52ce421b..e85cc543569a6e45fc1cc0f1c7b06148991b9a9d 100755 (executable)
@@ -6,4 +6,5 @@ Created on Fri Jul 31 21:23:51 2020
 @author: shane
 """
 
-# NOTE: based on <https://en.wikipedia.org/wiki/Nutritional_rating_systems#Naturally_Nutrient_Rich>
+# NOTE: based on
+#   <https://en.wikipedia.org/wiki/Nutritional_rating_systems#Naturally_Nutrient_Rich>
index 35c3b1ba520435ded78f0e13b3390dcf1b1f1187..994ec0c87da08d41d5622ebfc83b4b97aebeb0cc 100755 (executable)
@@ -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
index 12c579705fe88b71a3f907824ce806305858f4df..0a03c1be8aedd851824c374f71916e3864366bb0 100644 (file)
@@ -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
index 0789c2ff424941109c755a8c5acd2bcc994f9815..39fde645c055bfef0c1d0a40c117e4bef04a04d5 100644 (file)
@@ -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
index 04fe26d54fc6eeffa87faa4fbcbd3f049eb41a6b..960849d5022d5acb44b1894ef76649c396cac692 100644 (file)
--- 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
 
 
index 845829c5eafb0088078768dc06e2f168b53df42c..ca2ef8e52dd9a497dcdd8d799dd2f957603ca771 100644 (file)
--- 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()
index 6c6b1299c8a6454ef1a583808a3da68271022cf9..fa0583d375e594a02ff0e933726cfeb515f6617b 100644 (file)
@@ -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