Fortune Cookie Generator for python.
Project description
Python Package Exercise
Contributors
Lucia Song
Yeshni Savadatti
Chelsea Hodgson
Alan Zhao
Description
Get your fortune for Python!
Link to PyPi
Usage
This project allows users to receive randomly generated fortunes, either good or bad, by running commands in the terminal or by importing and using it as a module within a Python project. Users can create custom fortunes, generate a batch of random fortunes, or retrieve fortunes with a single function call.
Installing and Using this Package in a Virtual Environment
-
Clone this repo and make sure to cd into the root of this project directory with:
git clone git@github.com:software-students-fall2024/3-python-package-scooby-gang.git
cd 3-python-package-scooby-gang -
Make sure python is installed and install pipenv:
pip install pipenv OR pip3 install pipenv -
Activate the virtual environment:
pipenv shell -
Install the package within the virtual environment:
pip install python-fortune-cookie==0.1.0
Command Line
To use the fortune generator from the command line after installing the package and activating the virtual environment, navigate to the project’s root directory and use the following command:
python -m python_fortune_cookie
This will prompt you to choose between generating a custom fortune or choosing random fortunes. You will receive fortunes directly in the terminal based on your input.
Here’s a breakdown of the options:
Custom Fortune (c): When prompted, type c to enter a custom fortune. You’ll then be asked to enter the custom fortune text, which will appear in a fortune cookie image.
Random Fortunes (r): When prompted, type r to select a number of fortunes. You’ll then be asked how many fortunes you’d like (up to a maximum of 10). If you select more than 10 fortunes, the program will ask you to enter a valid amount.
Importing the package into a Separate Python Project
To use the fortune generator as a module within your Python project, import specific functions from FortuneCookie.py in your code:
from python_fortune_cookie import FortuneCookie
Here’s a brief description of each function and how to use it:
quoteGetter(fortuneAmount): Retrieves and prints a specified number of random good or bad fortunes. Returns a list of generated fortunes.
For example:
quoteGetter(10)
customFortuneCookie(userQuote): Prints a fortune cookie image with a custom fortune message passed as userQuote.
For example:
randomFortuneCookie("You will get ice cream.")
addQuote(userQuote, quoteType): Adds a custom fortune to either the good or bad fortune file. Specify quoteType as 'g' for good and 'b' for bad.
For example:
addQuote("You will get ice cream.", "g")
fortuneCookie(): Prints a blank fortune cookie image.
For example:
fortuneCookie()
randomFortuneCookie(fortuneAmount): Prints a specified number of random fortunes from both good and bad files.
For example:
randomFortuneCookie(5)
cookieScript(fortuneCustom): Simulates a process of creating or purchasing fortunes. Use 'c' for custom fortune and 'r' for random fortunes.
For example:
cookieScript("c")
Contributing
We welcome contributions! Here’s how you can help:
- Fork the Repository: Start by forking the repository and cloning your fork to your local machine.
- Create and Set up Virtual Environment: Set up a virtual environment with pipenv, using:
pip install pipenv OR pip3 install pipenv
and then:
pipenv shell - Install Dependencies: Make sure you have the necessary dependencies installed if pipenv was not used:
pip install -r requirements.txt OR pip3 install -r requirements.txt - Create a New Branch: Create a branch for your feature or bug fix.
- Make Changes and Write Tests: Make your changes, ensuring that you add or update tests as needed in the tests directory. To run tests, use the command:
python -m pytest OR python3 -m pytest - Commit and Push Your Changes: After finishing your work on local machine, commit and push your changes to git.
- Create a Pull Request: Go to the original repository and create a pull request for your changes.
Please ensure your codes come with meaningful commit messages and follow the PEP 8 standard, which can be found in detail here.
Project details
Release history Release notifications | RSS feed
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