Skip to main content

A fun Python package that provides jokes for developers

Project description

😂 Joke Center

CI

A fun and extensible Python package that provides jokes for developers. This project demonstrates how to design, test, package, and distribute a Python library using modern software engineering practices.


📦 PyPI

👉 PyPI

Install the package via:

pip install joke-center-wszms384

🚀 Features

  • Get random jokes by category
  • Add and delete jokes dynamically
  • Retrieve jokes across all categories
  • List available categories
  • Get multiple jokes at once
  • Built-in statistics support
  • Fully tested with pytest

🔧 Usage

import joke_center

# Get a joke
print(joke_center.get_joke("programming"))

# Add a joke
joke_center.add_joke(
    "programming",
    "Debugging is like being the detective in a crime movie where you are also the murderer."
)

# Get random joke
print(joke_center.get_random_joke())

# List categories
print(joke_center.list_categories())

👉 Full example program: Demo Code


📚 API Documentation

get_joke(category="programming")

Return a random joke from a given category.

joke_center.get_joke("dad")

add_joke(category, joke)

Add a new joke to a category.

joke_center.add_joke("dad", "I'm afraid for the calendar. Its days are numbered.")

delete_joke(category, joke)

Delete a joke from a category.

joke_center.delete_joke("dad", "Some joke")

list_categories()

Return all available categories.

joke_center.list_categories()

get_random_joke()

Return a random joke across all categories.

joke_center.get_random_joke()

get_all_jokes(category)

Return all jokes in a category.

joke_center.get_all_jokes("programming")

get_multiple_jokes(category, n=1)

Return up to n random jokes.

joke_center.get_multiple_jokes("dad", 2)

get_stats()

Return statistics about the joke database.

joke_center.get_stats()

🧪 Testing

Run tests using:

pipenv run python -m pytest

🛠️ Development Setup

1. Install pipenv

pip install pipenv

2. Create virtual environment

pipenv install

3. Install development dependencies

pipenv install pytest --dev
pipenv install build --dev
pipenv install twine --dev

🧪 Run Tests

pipenv run python -m pytest

📦 Build Package

pipenv run python -m build

🚀 Publish to PyPI

pipenv run twine upload dist/*

You will need to provide your PyPI API token when prompted.


⚙️ Project Configuration

This project uses pyproject.toml for package configuration.

Example:

[project]
name = "joke-center-wszms384"
version = "0.4.0"
description = "A fun Python package that provides jokes for developers"

🔐 Environment Variables

This project does not require any environment variables.

However, if publishing to PyPI, you must create a token:


📂 Example Configuration File

No .env file is required.

If needed in the future, you can create:

.env.example

Example content:

PYPI_TOKEN=your_token_here

⚠️ Notes

  • Data is stored in-memory only (not persistent)
  • Not thread-safe
  • Global state is mutable

📊 CI / Build Results

Latest workflow results:

  • Github Actions Workflow
  • Github Test Jobs

👨‍💻 Contributor


📄 License

GPL v3 License

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

joke_center_wszms384-0.5.0.tar.gz (44.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

joke_center_wszms384-0.5.0-py3-none-any.whl (31.6 kB view details)

Uploaded Python 3

File details

Details for the file joke_center_wszms384-0.5.0.tar.gz.

File metadata

  • Download URL: joke_center_wszms384-0.5.0.tar.gz
  • Upload date:
  • Size: 44.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for joke_center_wszms384-0.5.0.tar.gz
Algorithm Hash digest
SHA256 96ea7a2238cf1cff913d14973c60407855b70fa1e6e74958f183bf92590fe523
MD5 830f74b864f2686ec0625ff987f39608
BLAKE2b-256 feccdeae638eb542741edefeaeaa1224d79b263b6db57516be6ca132c35e4ae9

See more details on using hashes here.

File details

Details for the file joke_center_wszms384-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for joke_center_wszms384-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7282434a29bdcae400bbc2b629ed1df74f331c4271f4853537563629c1f61896
MD5 75999406fb9dd6cf3396baa5e7f11ef4
BLAKE2b-256 1834c85114edeace3d7545c7891b70c662b2e2aeed01e374ac5c8e82407f6bd4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page