DhanushNehru / Python-Scripts

A curated list of python scripts for automating your tasks
https://dhanushnehru.github.io/Python-Scripts/
MIT License
558 stars 262 forks source link

Add Caching Mechanism and Improved Error Handling in Currency Conversion Scripts #345

Closed Stonebanks-js closed 1 month ago

Stonebanks-js commented 1 month ago

Description:

_This pull request enhances the Currency.py and Currencycalculator.py scripts with the following features and improvements:

  • Caching Mechanism: Introduced a caching system in Currency_calculator.py to store exchange rates locally, minimizing API calls and allowing for offline support.
  • Enhanced Error Handling: Improved error handling in both scripts to manage invalid inputs, network issues, and unsupported currencies more effectively.
  • User-Friendly Prompts: Modified the input prompts for better clarity and usability.
  • Fixed API Integration: Corrected API endpoint usage, ensuring proper interaction with Fixer.io and FloatRates APIs.
  • Code Comments: Added comments throughout the scripts to explain the changes and new features for better code readability.

Changes Made:

Currency.py:

  • Added error handling for API requests.
  • Modified input prompts for better user experience.
  • Limited the precision of currency conversion to 2 decimal places.
  • Added inline comments explaining changes and new features.

_Currencycalculator.py:

  • Introduced a caching system to store exchange rates.
  • Added user-friendly messages for cache hits and misses.
  • Enhanced input validation to prevent erroneous conversions.
  • Included code comments to make the script more understandable.

Tests Conducted:

Checklist:

**- [ ] I have tested the code locally and ensured it works as expected.

Stonebanks-js commented 1 month ago

Sure @hasan-py will ping you soon once done

Stonebanks-js commented 1 month ago

@hasan-py i have closed this pull request, the files and block of code was having some trouble in resolving