Name | riddle-handler JSON |
Version |
1.0.4
JSON |
| download |
home_page | None |
Summary | A Python package for managing and interacting with a JSON-based riddle library. |
upload_time | 2024-11-02 23:25:55 |
maintainer | None |
docs_url | None |
author | None |
requires_python | None |
license | MIT |
keywords |
riddle
library
json
file handling
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
![Riddle Handler](https://github.com/software-students-fall2024/3-python-package-codecrafter/actions/workflows/riddle_package.yml/badge.svg)
## Riddle Handler
## Overview
**Riddle Handler** is a lighthearted Python package designed to bring a bit of joy and levity to developers' lives. It provides an interactive experience where users can generate riddles of varying difficulties and topics, check answers, submit new riddles, and receive hints. The package is built following rigorous software engineering practices, ensuring quality and reliability.
## PyPI Link
[Riddle Handler](https://pypi.org/project/riddle-handler/1.0.3/)
## Installation
Install the package via pip:
```bash
pip install riddle-handler==1.0.3
```
## Usage
### Importing the Package
```
import riddle_handler
```
### Functions and Examples
#### Function 1: `generate_riddle(difficulty: int) -> str`
Generates a random riddle based on the specified difficulty level.
- **Parameters:**
- `difficulty` (int): The difficulty level of the riddle (1 to 4).
- **Returns:**
- A string containing the riddle's question.
- **Example:**
```python
import riddle_handler
# Generate a riddle of difficulty level 2
riddle = riddle_handler.generate_riddle(2)
print(f"Here's your riddle: {riddle}")
```
#### Function 2: `check_answer(riddle_id: int, answer: str) -> str`
Checks if the provided answer to the riddle is correct.
- **Parameters:**
- `riddle_id` (int): The ID of the riddle.
- `answer` (str): The user's answer to the riddle.
- **Returns:**
- A string indicating whether the answer is correct or incorrect.
- **Example:**
```python
import riddle_handler
# Check the answer to a riddle with ID 5
result = riddle_handler.check_answer(5, 'shadow')
print(result) # Outputs: "Correct answer!" or "Incorrect answer. Try again!"
```
#### Function 3: `submit_riddle(riddle: dict) -> str`
Allows users to submit their own riddles to the library.
- **Parameters:**
- `riddle` (dict): A dictionary containing the riddle's details.
- `question` (str): The riddle's question.
- `answer` (list): A list of acceptable answers.
- `hint` (str): A hint for the riddle.
- `difficulty` (int): Difficulty level (1 to 4).
- `topic` (str): The topic of the riddle.
- **Returns:**
- A string indicating success or an error message.
- **Example:**
```python
import riddle_handler
# Define your custom riddle
my_riddle = {
"question": "I can move, yet I stay in one place; People use me to send messages, but I'm nowhere to be seen; Anytime, anywhere, you can call for me, and I'll always be there. What am I?",
"answer": ["sound"],
"hint": "You can hear me but cannot see me.",
"difficulty": 3,
"topic": "Communication"
}
# Submit the riddle
response = riddle_handler.submit_riddle(my_riddle)
print(response) # Outputs: "Riddle submitted successfully!"
```
#### Function 4: `provide_hint(riddle_id: int) -> str`
Provides a hint for the specified riddle.
- **Parameters:**
- `riddle_id` (int): The ID of the riddle.
- **Returns:**
- A string containing the hint or an error message.
- **Example:**
```python
import riddle_handler
# Get a hint for a riddle
hint = riddle_handler.provide_hint(5)
print(hint) # Outputs the hint for the riddle
```
_**For more examples, check out** [this example program](https://github.com/software-students-fall2024/3-python-package-codecrafter/blob/main/example_program.py)._
## Contributing
### Setting Up the Development Environment
1. **Clone the repository:**
```bash
git clone https://github.com/software-students-fall2024/3-python-package-codecrafter
```
2. **Install `pipenv`:**
If you haven’t installed `pipenv` yet, use the following command:
```bash
pip install pipenv
```
3. **Set Up the Virtual Environment:**
To create a virtual environment and install dependencies using the `Pipfile`, run:
```bash
pipenv install
```
This command will read the `Pipfile` and create a virtual environment with all the specified dependencies.
If you only want to create the environment without installing dependencies, you can use:
```bash
pipenv install --ignore-pipfile
```
4. **Activate the Virtual Environment:**
To activate the virtual environment, use:
```bash
pipenv shell
```
This command works on both Mac and Windows, as `pipenv` will automatically locate and activate the correct environment.
5. **Install Additional Dependencies(If Needed):**
If you need to add more dependencies later, you can use the following commands:
- For production dependencies:
```bash
pipenv install <package-name>
```
- For development dependencies (e.g., testing or debugging tools):
```bash
pipenv install --dev <package-name>
```
6. **Exit the Virtual Environment:**
To exit the virtual environment, simply type:
```bash
exit
```
Or press `Ctrl + D`.
7. **Remove the Virtual Environmen:**
If you need to delete the virtual environment, use:
```bash
pipenv --rm
```
This will remove the virtual environment associated with the `Pipfile`.
### Building and Testing
- **Run Tests:**
We use `pytest` for testing.
```bash
pytest
```
- **Build Package:**
Use `build` to create the package artifacts.
For Mac:
```bash
python3 -m build
```
For Windows:
```bash
python -m build
```
- **Upload to PyPI (For maintainers):**
Use `twine` to upload the package.
```bash
twine upload dist/*
```
Note that API key should only be acquired by contacting administrators
### Git Workflow
All code changes must be done in feature branches and not directly in the `main` branch.
To merge code from a feature branch into `main`:
1. **Create a pull request** from the feature branch to `main`.
2. **Request a code review** from a team member.
3. **Review and approve** the code after ensuring all tests pass.
4. **Merge the pull request** into `main`.
5. **Delete the feature branch**.
**Note:** Regularly merge feature branches to avoid merge conflicts.
## Contributors
- [Alex](https://github.com/alexyujiuqiao)
- [Haoyi](https://github.com/hw2782)
- [Keven](https://github.com/BlackCloud-K)
- [Nicole](https://github.com/niki531)
## Instructions for Running the Project
### For Developers
1. **Ensure Python 3.11 or higher is installed** on your system.
2. **Clone the repository and set up the environment** as described in the [Contributing](#contributing) section.
3. **Run the example program:**
For Mac:
```bash
python3 example_program.py
```
For Windows:
```bash
python example_program.py
```
### For Users
1. **Install the package via pip:**
```bash
install riddle-handler==1.0.3
```
2. **Use the package in your Python scripts** as shown in the [Usage](#usage) examples.
## Configuration and Setup
### Environment Variables
No environment variables are required for basic usage.
### Importing Starter Data
**The package uses a `riddleLibrary.json` file to store riddles. Ensure that this file is in the root directory of your project. You can use our library from [this link](https://github.com/software-students-fall2024/3-python-package-codecrafter/blob/main/riddleLibrary.json) or you can build your own by creating a `riddleLibrary.json` file.**
## Update Log
v1.0.3
Bug Fix: Resolved an issue where the package has no attribute.
v1.0.2
Bug Fix: Resolved an issue where the package appeared empty after installation.
Documentation: Updated README with clearer instructions and added installation and usage details specific to Windows.
Compatibility: Added a method for Windows users to ensure compatibility.
v1.0.1
Updated Package Structure: Reorganized the package structure to follow best practices for module organization, enhancing maintainability and usability.
Bug Fixes: Resolved several issues related to imports and file path references, improving the stability and reliability of the package.
v1.0.0
Initial Release: Launched the riddle_handler package, offering core functionalities for managing and interacting with a JSON-based riddle library. This includes generating riddles, checking answers, providing hints, and submitting new riddles.
Raw data
{
"_id": null,
"home_page": null,
"name": "riddle-handler",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "riddle, library, JSON, file handling",
"author": null,
"author_email": "code crafters <bw2176@nyu.edu>",
"download_url": "https://files.pythonhosted.org/packages/4a/bc/7442990b04c3e5bb0f6016bbc4d5aa9f7f6071e406d90ea9dae29904e6eb/riddle_handler-1.0.4.tar.gz",
"platform": null,
"description": "![Riddle Handler](https://github.com/software-students-fall2024/3-python-package-codecrafter/actions/workflows/riddle_package.yml/badge.svg)\n## Riddle Handler\n\n## Overview\n\n**Riddle Handler** is a lighthearted Python package designed to bring a bit of joy and levity to developers' lives. It provides an interactive experience where users can generate riddles of varying difficulties and topics, check answers, submit new riddles, and receive hints. The package is built following rigorous software engineering practices, ensuring quality and reliability.\n## PyPI Link\n[Riddle Handler](https://pypi.org/project/riddle-handler/1.0.3/)\n\n## Installation\n\nInstall the package via pip:\n\n```bash\npip install riddle-handler==1.0.3\n```\n\n## Usage\n\n### Importing the Package\n\n```\nimport riddle_handler\n```\n\n### Functions and Examples\n\n#### Function 1: `generate_riddle(difficulty: int) -> str`\n\nGenerates a random riddle based on the specified difficulty level.\n\n- **Parameters:**\n - `difficulty` (int): The difficulty level of the riddle (1 to 4).\n\n- **Returns:**\n - A string containing the riddle's question.\n\n- **Example:**\n\n ```python\n import riddle_handler\n\n # Generate a riddle of difficulty level 2\n riddle = riddle_handler.generate_riddle(2)\n print(f\"Here's your riddle: {riddle}\")\n ```\n\n#### Function 2: `check_answer(riddle_id: int, answer: str) -> str`\n\nChecks if the provided answer to the riddle is correct.\n\n- **Parameters:**\n - `riddle_id` (int): The ID of the riddle.\n - `answer` (str): The user's answer to the riddle.\n\n- **Returns:**\n - A string indicating whether the answer is correct or incorrect.\n\n- **Example:**\n\n ```python\n import riddle_handler\n\n # Check the answer to a riddle with ID 5\n result = riddle_handler.check_answer(5, 'shadow')\n print(result) # Outputs: \"Correct answer!\" or \"Incorrect answer. Try again!\"\n ```\n\n#### Function 3: `submit_riddle(riddle: dict) -> str`\n\nAllows users to submit their own riddles to the library.\n\n- **Parameters:**\n - `riddle` (dict): A dictionary containing the riddle's details.\n\n - `question` (str): The riddle's question.\n - `answer` (list): A list of acceptable answers.\n - `hint` (str): A hint for the riddle.\n - `difficulty` (int): Difficulty level (1 to 4).\n - `topic` (str): The topic of the riddle.\n\n- **Returns:**\n - A string indicating success or an error message.\n\n- **Example:**\n\n ```python\n import riddle_handler\n\n # Define your custom riddle\n my_riddle = {\n \"question\": \"I can move, yet I stay in one place; People use me to send messages, but I'm nowhere to be seen; Anytime, anywhere, you can call for me, and I'll always be there. What am I?\",\n \"answer\": [\"sound\"],\n \"hint\": \"You can hear me but cannot see me.\",\n \"difficulty\": 3,\n \"topic\": \"Communication\"\n }\n\n # Submit the riddle\n response = riddle_handler.submit_riddle(my_riddle)\n print(response) # Outputs: \"Riddle submitted successfully!\"\n ```\n\n#### Function 4: `provide_hint(riddle_id: int) -> str`\n\nProvides a hint for the specified riddle.\n\n- **Parameters:**\n - `riddle_id` (int): The ID of the riddle.\n\n- **Returns:**\n - A string containing the hint or an error message.\n\n- **Example:**\n\n ```python\n import riddle_handler\n\n # Get a hint for a riddle\n hint = riddle_handler.provide_hint(5)\n print(hint) # Outputs the hint for the riddle\n ```\n\n\n_**For more examples, check out** [this example program](https://github.com/software-students-fall2024/3-python-package-codecrafter/blob/main/example_program.py)._\n\n## Contributing\n\n### Setting Up the Development Environment\n\n1. **Clone the repository:**\n\n ```bash\n git clone https://github.com/software-students-fall2024/3-python-package-codecrafter\n ```\n\n2. **Install `pipenv`:**\n\nIf you haven\u2019t installed `pipenv` yet, use the following command:\n\n```bash\npip install pipenv\n```\n\n3. **Set Up the Virtual Environment:**\n\nTo create a virtual environment and install dependencies using the `Pipfile`, run:\n\n```bash\npipenv install\n```\n\nThis command will read the `Pipfile` and create a virtual environment with all the specified dependencies.\n\nIf you only want to create the environment without installing dependencies, you can use:\n\n```bash\npipenv install --ignore-pipfile\n```\n\n4. **Activate the Virtual Environment:**\n\nTo activate the virtual environment, use:\n\n```bash\npipenv shell\n```\n\nThis command works on both Mac and Windows, as `pipenv` will automatically locate and activate the correct environment.\n\n5. **Install Additional Dependencies(If Needed):**\n\nIf you need to add more dependencies later, you can use the following commands:\n\n- For production dependencies:\n\n ```bash\n pipenv install <package-name>\n ```\n\n- For development dependencies (e.g., testing or debugging tools):\n\n ```bash\n pipenv install --dev <package-name>\n ```\n\n6. **Exit the Virtual Environment:**\n\nTo exit the virtual environment, simply type:\n\n```bash\nexit\n```\n\nOr press `Ctrl + D`.\n\n7. **Remove the Virtual Environmen:**\n\nIf you need to delete the virtual environment, use:\n\n```bash\npipenv --rm\n```\n\nThis will remove the virtual environment associated with the `Pipfile`.\n\n\n### Building and Testing\n\n- **Run Tests:**\n\n We use `pytest` for testing.\n\n ```bash\n pytest\n ```\n\n- **Build Package:**\n\n Use `build` to create the package artifacts.\n \n For Mac:\n\n\n ```bash\n python3 -m build\n ```\n\n For Windows:\n\n\n ```bash\n python -m build\n ```\n\n- **Upload to PyPI (For maintainers):**\n\n Use `twine` to upload the package.\n\n ```bash\n twine upload dist/*\n ```\n\n Note that API key should only be acquired by contacting administrators\n\n### Git Workflow\n\nAll code changes must be done in feature branches and not directly in the `main` branch.\n\nTo merge code from a feature branch into `main`:\n\n1. **Create a pull request** from the feature branch to `main`.\n2. **Request a code review** from a team member.\n3. **Review and approve** the code after ensuring all tests pass.\n4. **Merge the pull request** into `main`.\n5. **Delete the feature branch**.\n\n**Note:** Regularly merge feature branches to avoid merge conflicts.\n\n## Contributors\n\n- [Alex](https://github.com/alexyujiuqiao)\n- [Haoyi](https://github.com/hw2782)\n- [Keven](https://github.com/BlackCloud-K)\n- [Nicole](https://github.com/niki531)\n\n## Instructions for Running the Project\n\n### For Developers\n\n1. **Ensure Python 3.11 or higher is installed** on your system.\n\n2. **Clone the repository and set up the environment** as described in the [Contributing](#contributing) section.\n\n3. **Run the example program:**\n \n For Mac:\n\n ```bash\n python3 example_program.py\n ```\n\n For Windows:\n\n ```bash\n python example_program.py\n ```\n\n### For Users\n\n1. **Install the package via pip:**\n\n ```bash\n install riddle-handler==1.0.3\n ```\n\n2. **Use the package in your Python scripts** as shown in the [Usage](#usage) examples.\n\n## Configuration and Setup\n\n### Environment Variables\n\nNo environment variables are required for basic usage.\n\n### Importing Starter Data\n\n**The package uses a `riddleLibrary.json` file to store riddles. Ensure that this file is in the root directory of your project. You can use our library from [this link](https://github.com/software-students-fall2024/3-python-package-codecrafter/blob/main/riddleLibrary.json) or you can build your own by creating a `riddleLibrary.json` file.**\n\n## Update Log\nv1.0.3\nBug Fix: Resolved an issue where the package has no attribute.\n\nv1.0.2\nBug Fix: Resolved an issue where the package appeared empty after installation.\nDocumentation: Updated README with clearer instructions and added installation and usage details specific to Windows.\nCompatibility: Added a method for Windows users to ensure compatibility.\n\nv1.0.1\nUpdated Package Structure: Reorganized the package structure to follow best practices for module organization, enhancing maintainability and usability.\nBug Fixes: Resolved several issues related to imports and file path references, improving the stability and reliability of the package.\n\nv1.0.0\nInitial Release: Launched the riddle_handler package, offering core functionalities for managing and interacting with a JSON-based riddle library. This includes generating riddles, checking answers, providing hints, and submitting new riddles.\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python package for managing and interacting with a JSON-based riddle library.",
"version": "1.0.4",
"project_urls": null,
"split_keywords": [
"riddle",
" library",
" json",
" file handling"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "608b527fc918893ad56fc209b7fad696a63b9b70306d4b752a7684e98b54e869",
"md5": "21dfd452a404d36ce77b9c946e7bb4b5",
"sha256": "8362b6e5dbabd2bdc01745e1a4ff626af68b3c7e4ac4ce2585962097482685e3"
},
"downloads": -1,
"filename": "riddle_handler-1.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "21dfd452a404d36ce77b9c946e7bb4b5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 19527,
"upload_time": "2024-11-02T23:25:53",
"upload_time_iso_8601": "2024-11-02T23:25:53.816829Z",
"url": "https://files.pythonhosted.org/packages/60/8b/527fc918893ad56fc209b7fad696a63b9b70306d4b752a7684e98b54e869/riddle_handler-1.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4abc7442990b04c3e5bb0f6016bbc4d5aa9f7f6071e406d90ea9dae29904e6eb",
"md5": "5e779e0a08e1799ac154bca0cf3a4280",
"sha256": "81e0654b4096376b2e8854b69759961c93a35561dfdda60e2862435c40855348"
},
"downloads": -1,
"filename": "riddle_handler-1.0.4.tar.gz",
"has_sig": false,
"md5_digest": "5e779e0a08e1799ac154bca0cf3a4280",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 20758,
"upload_time": "2024-11-02T23:25:55",
"upload_time_iso_8601": "2024-11-02T23:25:55.199227Z",
"url": "https://files.pythonhosted.org/packages/4a/bc/7442990b04c3e5bb0f6016bbc4d5aa9f7f6071e406d90ea9dae29904e6eb/riddle_handler-1.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-02 23:25:55",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "riddle-handler"
}