***********
- 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>`_.
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.
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
~~~~~
~~~~~
- 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.
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.
~~~~~
- 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.
Added
~~~~~
-- Support for analysis of day CSV files
+- Support for analysis of "day" ``CSV`` files.
::
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
--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
# Package info
__title__ = "nutra"
-__version__ = "0.2.5.dev1"
+__version__ = "0.2.5"
__author__ = "Shane Jaroch"
__email__ = "chown_tee@proton.me"
__license__ = "GPL v3"
@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>
################################################################################
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)
################################################################################
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
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
# 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
# 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
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()
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)
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():
"""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 = (
"""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:
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