Amazing-Python-Scripts icon indicating copy to clipboard operation
Amazing-Python-Scripts copied to clipboard

Nutritional info script

Open AdithyaBollu opened this issue 3 months ago β€’ 2 comments

Description

Hello, I have added a new script for retrieving the nutritional facts of different food items by making a call to a free API called Calorie Ninjas.

Type of change

Type of change<!--

Thank you for sending the PR! We appreciate you spending the time to work on these changes. Help us understand your motivation by explaining why you decided to make this change. Happy Contributing! -->

Please delete options that are not relevant.

  • [x] New feature (non-breaking change which adds functionality)

Checklist:

  • [x] My code follows the style guidelines(Clean Code) of this project
  • [x] I have performed a self-review of my own code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] I have created a helpful and easy to understand README.md
  • [x] My documentation follows Template for README.md
  • [x] I have added the project meta data in the PR template.
  • [x] I have created the requirements.txt file if needed.

Project Metadata

If there is no-file/nothing to fill the below fields with, then type: none

Example: If no requirements.txt needed/present, then type none in Requirments.

Category:

  • [ ] Calculators
  • [ ] AI/ML
  • [ ] Scrappers
  • [ ] Social_Media
  • [ ] PDF
  • [ ] Image_Processing
  • [ ] Video_Processing
  • [ ] Games
  • [ ] Networking
  • [ ] OS_Utilities
  • [ ] Automation
  • [ ] Cryptography
  • [ ] Computer_Vision
  • [x] Fun
  • [ ] Others

Title: <Nutrition Facts Script>

Folder: <Nutritional-Facts>

Requirements: <requests>

Script: <nutrition>

Arguments: <query>

Contributor: <AdithyaBollu>

Description: <Gets nutrition facts of your favorite food items! :)>

Summary by Sourcery

Add a new interactive nutrition information script that fetches and displays nutritional facts for foods using the CalorieNinjas API

New Features:

  • Implement get_nutrition_info function to query the CalorieNinjas API and return nutrient data
  • Build a CLI in nutrition.py to prompt users for food items, handle quit commands, and format output

Build:

  • Include requirements.txt listing all dependencies for the nutrition script

Documentation:

  • Add README with setup instructions, API key configuration, usage examples, and author information

AdithyaBollu avatar Oct 02 '25 06:10 AdithyaBollu

Reviewer's Guide

This PR introduces a new command-line script that fetches and displays nutritional facts for user-entered food queries via the CalorieNinjas API, along with accompanying documentation and dependency management.

Sequence diagram for user querying nutritional facts

sequenceDiagram
    actor User
    participant "nutrition.py"
    participant "CalorieNinjas API"
    User->>"nutrition.py": Enter food query
    "nutrition.py"->>"CalorieNinjas API": GET /v1/nutrition?query={food}
    "CalorieNinjas API"-->>"nutrition.py": Nutrition facts response
    "nutrition.py"->>User: Display nutrition facts or error message

File-Level Changes

Change Details Files
Implement nutrition facts CLI script with API integration
  • Define get_nutrition_info to perform HTTP GET with API key and parse JSON
  • Implement print_info to format and display nutrition data
  • Build interactive main loop to prompt, process β€˜quit’ command, and iterate over results
Nutritional-Facts/nutrition.py
Add setup and usage documentation
  • Create README.md with installation steps, API key instructions, and usage examples
  • Include screenshots placeholders and author metadata
Nutritional-Facts/README.md
Add requirements file for dependencies
  • Generate requirements.txt listing all necessary packages including requests
  • Pin versions for reproducible environment
Nutritional-Facts/requirements.txt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an issue from a review comment by replying to it. You can also reply to a review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull request title to generate a title at any time. You can also comment @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment @sourcery-ai summary on the pull request to (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

  • Contact our support team for questions or feedback.
  • Visit our documentation for detailed guides and information.
  • Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.

sourcery-ai[bot] avatar Oct 02 '25 06:10 sourcery-ai[bot]

Hello, I am confused as to why I am failing the DeepSource: Python check even though I have documented everything pretty well.

AdithyaBollu avatar Oct 02 '25 06:10 AdithyaBollu