Giter Site home page Giter Site logo

trellixvulnteam / cli_fcus Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nutratech/cli

0.0 0.0 0.0 80 KB

Command line Python application for interacting with government food databases

License: GNU General Public License v3.0

Python 95.66% Mathematica 0.76% Makefile 3.58%

cli_fcus's Introduction

nutratracker

Command line tools for interacting with government food database, and analyzing your health trends. The SR28 database includes data for ~8500 foods and ~180 nutrients. Customizable with extensions and mapping rules built on top.

Requires

  • Python 3.4.0 or later (lzma, ssl & sqlite3 modules) [Win XP / Ubuntu 14.04].
  • Packages: see setup.py, and requirements.txt files.
  • Internet connection, to download food database & package dependencies.

See nt database: https://github.com/nutratech/nt-sqlite

See usda database: https://github.com/nutratech/usda-sqlite

Details

Category    
Install / Linux Test status unknown (Linux)  
Install / Windows Test status unknown (Windows)  
Other checks Coverage unknown Lint status unknown
PyPI Release Latest version unknown Monthly downloads unknown
Supported Runtime Python3 (3.4 - 3.10)  
Code Style Code style: black  
License License GPL-3  

Linux / macOS requirements (for development)

You will need to install make and gcc to build the Levenshtein extension.

sudo apt install \
  make gcc \
  python3-dev python3-venv \
  direnv

You can add the direnv hook, direnv hook bash >>~.bashrc. Only run this once.

Plugin Development

You can develop plugins (or data modifications sets) that are imported and built on the base (or core) installation.

Supporting Old Versions of Python

The old requirements can still be tested on modern interpreters. Simply install them with this (inside your venv environment).

pip install -r requirements-old.txt

This won't guarantee compatibility for every version, but it will help. We provide a wide range. The oldest version of tabulate is from 2013.

To use an old interpreter (Python 3.4 does not have the typing module! Only collections.abc.) you may need to use a virtual machine or install old SSL libraries or enter a similar messy state. My preference is for VirtualBox images, where I manually test Windows XP & Ubuntu 14.04.

Notes

On Windows you should check the box during the Python installer to include Scripts directory in your $PATH. This can be done manually after installation too.

Windows users may also have differing results if they install for all users (as an administrator) vs. installing just for themselves. It may change the location of installed scripts, and affect the $PATH variable being correctly populated for prior installs.

Linux may need to install python-dev package to build python-Levenshtein. I am currently debating making this an optional dependency to avoid confusing install failures for people without gcc or python3-dev.

I'm also currently working on doing phased installs of dependencies based on the host Python version, since some of the old versions of pip have trouble finding something that works, and again, spit out confusing errors.

Windows users may not be able to install python-Levenshtein.

Main program works 100%, but test and lint may break on older operating systems (Ubuntu 14.04, Windows XP).

Install PyPi release (from pip)

pip install -U nutra

(Specify: flag -U to upgrade, or --pre for development releases)

Using the source code directly

Clone down, initialize nt-sqlite submodule, and install requirements:

git clone https://github.com/nutratech/cli.git
cd cli
make init
# source .venv/bin/activate  # uncomment if NOT using direnv
make deps

./nutra -h

Initialize the DBs (nt and usda).

# source .venv/bin/activate  # uncomment if NOT using direnv
./nutra init

# Or install and run as package script
make install
n init

If installed (or inside cli) folder, the program can also run with python -m ntclient.

You may need to set the PY_SYS_INTERPRETER value for the Makefile if trying to install other than with /usr/bin/python3.

Building the PyPi release (sdist)

# source .venv/bin/activate  # uncomment if NOT using direnv
make build  # python3 setup.py --quiet sdist
twine upload dist/nutra-X.X.X.tar.gz

Linting & Tests

Install the dependencies (make deps). Now you can lint & test.

# source .venv/bin/activate  # uncomment if NOT using direnv
make format lint test

ArgComplete (tab completion / autocomplete)

The argcomplete package will be installed alongside.

Linux, macOS, and Linux Subsystem for Windows

Simply run the following out of a bash shell. Check their page for more specifics on using other shells, e.g. zsh, fish, or tsh.

activate-global-python-argcomplete --user

Then you can press tab to fill in or complete sub-commands and to list argument flags.

Windows (Git Bash)

This can work with git bash too. I followed the instructions on their README.

I've run the command to seed the autocomplete script.

mkdir -p $HOME/.bash_completion.d
activate-global-python-argcomplete --user

And my ~/.bashrc file looks like this.

export ARGCOMPLETE_USE_TEMPFILES=1

# python bash completion
if [ -f ~/.bash_completion.d/python-argcomplete ]; then
    source ~/.bash_completion.d/python-argcomplete
fi

NOTE: This is a work in progress, we are adding more autocomplete functions.

Currently Supported Data

USDA Stock database

  • Standard reference database (SR28) [7794 foods]

Relative USDA Extensions

  • Flavonoid, Isoflavonoids, and Proanthocyanidins [1352 foods]

Usage

Requires internet connection to download initial datasets. Run nutra init for this step.

Run the n script to output usage.

cli_fcus's People

Contributors

gamesguru avatar trellixvulnteam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.