A funny fortunes generator package
Project description
Python Package Exercise
An exercise to create a Python package, build it, test it, distribute it, and use it. See instructions for details.
🔮 Fortunes
👥 Team Members
Description
Fortunes is a delightful Python package that brings a touch of randomness and inspiration into your projects. Whether you're looking for a daily dose of wisdom, a lucky number, or the ability to send personalized fortunes via email, Fortunes has you covered.
Features
- Random Fortune Generation: Retrieve one or multiple unique fortunes along with lucky numbers.
- Email Integration: Send personalized fortunes to any email address effortlessly.
- Customizable Quotes: Get your own collection of fortunes and quotes.
📦 Installation
Install the latest version of Fortunes from PyPI using pip:
pip install fortune.package
📖 Documentation
Importing Fortunes into Your Project
To start using Fortunes in your Python code, simply import the desired functions:
from fortunes.random_fortune import get_fortune_cookie
from fortunes.get_quotes_by_author import get_quotes_by_author
from fortunes.send_email import send_fortune_email
from fortunes.getMultipleFortunes import getMultipleFortunes
# Example Usage:
fortune = get_fortune_cookie()
print(fortune)
quotes = get_quotes_by_author(quotes_dict)
print(quotes)
send_fortune_email("recipient@example.com", fortune)
multiple_fortunes = getMultipleFortunes(3)
for f in multiple_fortunes:
print(f)
Function Documentation
get_fortune_cookie()
Description:
Generates a single random fortune along with a lucky number.
Usage:
from fortunes.random_fortune import get_fortune_cookie
fortune = get_fortune_cookie()
print(fortune)
Output Example:
🔮 Your Fortune: Good luck is on the way!
🍀 Your Lucky Number: 42
get_quotes_by_author(quotes_dict)
Description:
Retrieves quotes from a specified author. Users can choose to get one or multiple quotes.
Usage:
from fortunes.get_quotes_by_author import get_quotes_by_author
quotes_dict = {
"Albert Claude": [
"Once Ptolemy and Plato, yesterday Newton, today Einstein, and tomorrow new faiths, new beliefs, and new dimensions.",
"When I went to the University, the medical school was the only place where one could hope to find the means to study life, its nature, its origins, and its ills.",
"Looking back 25 years later, what I may say is that the facts have been far better than the dreams. In the long course of cell life on this earth it remained, for our age for our generation, to receive the full ownership of our inheritance.",
],
"Mikhail Bakunin": [
"The urge to destroy is also a creative urge.",
"If God really existed, it would be necessary to abolish Him.",
"People go to church for the same reasons they go to a tavern: to stupefy themselves, to forget their misery, to imagine themselves, for a few minutes anyway, free and happy."
]
}
quotes = get_quotes_by_author(quotes_dict)
print(quotes)
Output Example:
🔮 Your Fortune: The urge to destroy is also a creative urge.
🍀 Your Lucky Number: 17
~ Mikhail Bakunin
🔮 Your Fortune: If God really existed, it would be necessary to abolish Him.
🍀 Your Lucky Number: 23
~ Mikhail Bakunin
send_fortune_email(recipient_email, fortune)
Description:
Sends a fortune to the specified email address.
Usage:
from fortunes.send_email import send_fortune_email
recipient = "friend@example.com"
fortune = "🔮 Your Fortune: Happiness is around the corner.\n🍀 Your Lucky Number: 12"
send_fortune_email(recipient, fortune)
Note:
Ensure that you have the necessary SMTP configurations and environment variables set up before using this function.
getMultipleFortunes(n)
Description:
Generates multiple unique fortunes based on the number specified.
Usage:
from fortunes.getMultipleFortunes import getMultipleFortunes
fortunes = getMultipleFortunes(3)
for f in fortunes:
print(f)
Output Example:
🔮 Your Fortune: Fortune 1
🍀 Your Lucky Number: 42
🔮 Your Fortune: Fortune 2
🍀 Your Lucky Number: 88
🔮 Your Fortune: Fortune 3
🍀 Your Lucky Number: 7
📂 Example Programs
For comprehensive examples of how to use Fortunes in real-world scenarios, refer to our examples directory on GitHub.
🤝 Contributing
We welcome contributions from the community! Here's how you can get started:
🛠️ Setup Development Environment
-
Clone the Repository:
git clone https://github.com/yourusername/fortunes.git cd fortunes
-
Create a Virtual Environment:
python3 -m venv venv source venv/bin/activate # On Windows, use venv\Scripts\activate
-
Install Dependencies:
pip install --upgrade pip pip install -e .[dev]
This installs the package in editable mode along with development dependencies.
-
Install requirements:
pip install -r requirements.txt
-
Run Tests:
Ensure that all tests pass before making changes.
pytest
Making Changes
-
Create a New Branch:
git checkout -b feature/your-feature-name
-
Implement Your Changes:
Make your desired changes to the codebase.
-
Run Tests:
Ensure that your changes do not break existing functionality.
pytest
-
Commit and Push:
git add . git commit -m "Add feature: your-feature-description" git push origin feature/your-feature-name
-
Open a Pull Request:
Navigate to the repository on GitHub and open a pull request detailing your changes.
📝 Guidelines
- Follow PEP 8: Ensure your code adheres to Python's style guidelines.
- Write Tests: Add tests for new features or bug fixes.
- Document Your Code: Update documentation to reflect changes.
🚀 Getting Started
📋 Prerequisites
- Python 3.10+
- pip
- Virtual Environment Tool (optional)
🛠️ Configuration and Setup
-
Clone the Repository:
git clone https://github.com/yourusername/fortunes.git cd fortunes
-
Set Up Virtual Environment:
python3 -m venv venv source venv/bin/activate # On Windows, use venv\Scripts\activate
-
Install Dependencies:
pip install --upgrade pip pip install -e .[dev]
Running the Project
-
Generating a Fortune:
from fortunes.random_fortune import get_fortune_cookie fortune = get_fortune_cookie() print(fortune)
-
Sending a Fortune via Email:
from fortunes.send_email import send_fortune_email recipient = "friend@example.com" fortune = "🔮 Your Fortune: Happiness is around the corner.\n🍀 Your Lucky Number: 12" send_fortune_email(recipient, fortune)
-
Retrieving Quotes by Author:
from fortunes.get_quotes_by_author import get_quotes_by_author quotes_dict = { "Albert Claude": [ "Once Ptolemy and Plato, yesterday Newton, today Einstein, and tomorrow new faiths, new beliefs, and new dimensions.", # Add more quotes... ], # Add more authors... } quotes = get_quotes_by_author(quotes_dict) for q in quotes: print(q)
Platform Compatibility
Fortunes is designed to work seamlessly across all major platforms, including:
- Windows
- macOS
- Linux
Ensure that Python 3.10 or higher is installed on your system.
🔒 Handling Secret Configuration Files (Optional)
Important:
Configuration files containing sensitive information, such as .env, are not included in the version control repository for security reasons.
📄 Creating a .env File
-
Create the File:
In the root directory of your project, create a file named
.env. -
Add the Following Content:
SMTP_SERVER=smtp.gmail.com SMTP_PORT=587 SMTP_USERNAME=your_email@gmail.com SMTP_PASSWORD=your_email_password
Explanation of Variables:
SMTP_SERVER: The address of your SMTP server.SMTP_PORT: The port number for your SMTP server (commonly587for TLS).SMTP_USERNAME: Your SMTP server username (usually your email address).SMTP_PASSWORD: Your SMTP server password.
-
Secure Your Credentials:
- Do Not Share: Never share your
.envfile or its contents publicly. - Add to
.gitignore: Ensure that your.envfile is listed in.gitignoreto prevent it from being tracked by Git.
# .gitignore __pycache__/ *.pyc build/ dist/ *.egg-info/ .env
- Do Not Share: Never share your
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fortune_package-0.1.5.tar.gz.
File metadata
- Download URL: fortune_package-0.1.5.tar.gz
- Upload date:
- Size: 23.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe2a6bab670434ba7185c644612ba81ae60819213455a6845d3825e906d75489
|
|
| MD5 |
c9f2001e993a7a3e35b3c39eaef3d342
|
|
| BLAKE2b-256 |
97abfb38bb1b06bc6cd43bfaa60960f0bbeeaec6af8345d8abee87ebf83eb61a
|
File details
Details for the file fortune_package-0.1.5-py3-none-any.whl.
File metadata
- Download URL: fortune_package-0.1.5-py3-none-any.whl
- Upload date:
- Size: 21.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38cbd5c102142f03a046fdbb8a861aef0eb17a96e71fc9d174013bd47cf1e355
|
|
| MD5 |
eea4ae896e8b9a2c08c652a35942da50
|
|
| BLAKE2b-256 |
770e5b5c8f3f82d988ec14e80ae591e3d6087ec67f1119a15776a35734ffebb9
|