Skip to main content

A Python package for function execution status and spinner output

Project description

Formatter and Example

This project demonstrates the use of a Python decorator to format the output of functions, showing a running spinner, and indicating success or failure with colored and formatted text. It includes two files: formatter.py and example.py.

Example Output

Files

  1. formatter.py: This file contains the format_output decorator that provides the desired formatting for function output.
  2. example.py: This file demonstrates how to use the format_output decorator by applying it to two example functions, one that succeeds and one that fails.

Features

  • Spinner Animation: Displays a spinner animation while the function is running.
  • Success/Failure Indication: Shows a green checkmark for successful completion and a red cross for failures.
  • Exception Handling: Exceptions are displayed in red and underlined.
  • Function Numbering: Each function is prefixed with a unique number.
  • Text Formatting: Function names are displayed in bold and underlined.
  • Separation of Outputs: Outputs from different functions are separated by a line for clarity.

Usage

1. formatter.py

The format_output decorator is defined in this file. It wraps a function to display the running spinner, success/failure message, and handle exceptions.

2. example.py

The example.py file demonstrates the use of the format_output decorator. It includes two functions, one that succeeds and one that fails, to showcase the decorator's functionality.

Running the Example

  1. Save formatter.py and example.py in the same directory.
  2. Run example.py using the command:
python example.py

You should see the spinner, success, and failure messages formatted as described, with appropriate separation and formatting for each function's output.

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

TaskFormatter-0.1.0.tar.gz (2.0 kB view details)

Uploaded Source

Built Distribution

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

TaskFormatter-0.1.0-py3-none-any.whl (2.0 kB view details)

Uploaded Python 3

File details

Details for the file TaskFormatter-0.1.0.tar.gz.

File metadata

  • Download URL: TaskFormatter-0.1.0.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for TaskFormatter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d691b207d816d5aec098ec13e89d91b9e69d47e86181169be73f1e1d4c27eea2
MD5 1f00929dcb343200fce24dfb039dfec8
BLAKE2b-256 74e856b650ddceeafbc1ea4ccc24ca4d677d478470386c45efa313d868b5e70e

See more details on using hashes here.

File details

Details for the file TaskFormatter-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: TaskFormatter-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for TaskFormatter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d9e7d88233ff3fabdcbd867039931ec21be49f2418e0b047d941e4d76405a70
MD5 5702a19f4e44390894f31b371928e532
BLAKE2b-256 a7c9edf9d9e3a1e6dafde5f435c5a35d6e5030ff10eb7a43cc5e7e2e745c6a97

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