Skip to main content

A Python package for various utilities

Project description

A simple package containing various command-line utilities.

Table of Contents

Caution

This package does not have any tests. It is not recommended to use this package in production. I wrote this package for my own personal use. I don't have any immediate plans to add tests to this package and make it production-ready. Use this package at your own risk.

Installation

  pip install mizue

Utilities (Work in Progress)

Printer

This class contains various static methods for printing text in different colors.

from mizue.printer import Printer

Printer.print_hex('Hello World!', '#ff0000')
Printer.print_rgb('Hello World!', (255, 0, 0))

Following is a list of some of the methods available in this class:

  • format_hex(text, text_color, background_color=None, bold=False, underline=False)
  • format_rgb(text, rgb_color, background_color=None, bold=False, underline=False)
  • print_hex(text, text_color, background_color=None, bold=False, underline=False)
  • print_rgb(text, rgb_color, background_color=None, bold=False, underline=False)
  • error(text)
  • warning(text)
  • info(text)
  • success(text)

Using the format_* methods, you can format text and use it later. For example:

from mizue.printer import Printer
colored_text = Printer.format_hex('Hello World!', '#ff0000')
print(colored_text)

Progress

This is a simple class for displaying progress bars in the terminal.

from mizue.progress import Progress
from time import sleep

progress = Progress(0, 1200, 0) # (start, end, current)
progress.label = 'Progress: ' # This text is displayed before the progress bar
progress.info_text = '(in progress)' # This text is displayed after the progress bar
progress.start()

for i in range(1200):
  progress.update_value(i)
  sleep(0.01)

progress.stop()

Progress allows the following attributes to be set:

  • info_separator: The character to be used to separate the info text from the progress bar
  • info_separaotr_renderer: A function that takes in an object of type InfoSeparatorRendererArgs and returns a string to be used to separate the info text from the progress bar
  • info_text: Text to be displayed after the progress bar
  • info_text_renderer: A function that takes in an object of type InfoTextRendererArgs and returns a string to be displayed after the progress bar
  • label: Text to be displayed before the progress bar
  • label_renderer: A function that takes in an object of type LabelRendererArgs and returns a string to be displayed before the progress bar
  • progress_bar_renderer: A function that takes in an object of type ProgressBarRendererArgs and returns a string to be displayed as the progress bar
  • percentage_renderer: A function that takes in an object of type PercentageRendererArgs and returns a string to be displayed as the percentage
  • spinner_renderer: A function that takes in an object of type SpinnerRendererArgs and returns a string to be displayed as the spinner

An example of rendering a custom label (appears before the progress bar):

from mizue.progress import Progress
from mizue.progress import LabelRendererArgs
from mizue.printer import Printer
from time import sleep

def label_renderer(args: LabelRendererArgs) -> str:
  return Printer.format_hex(args.label, '#ff0000') \
    if args.percentage < 50 \ 
    else Printer.format_hex(args.label, '#00ff00')

progress = Progress(0, 1200, 0)
progress.label_renderer = label_renderer
progress.start()

for i in range(1200):
  progress.update_value(i)
  sleep(0.1)

progress.stop()

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

mizue-0.3.1.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

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

mizue-0.3.1-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file mizue-0.3.1.tar.gz.

File metadata

  • Download URL: mizue-0.3.1.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for mizue-0.3.1.tar.gz
Algorithm Hash digest
SHA256 2be464d63419b59983c6bd5a1869643f3f1930332f7213f2dd507c2f488ed13a
MD5 a50b4222d59089bbe097b90688f5e480
BLAKE2b-256 c55848b9388f110e29764573fa60541b37bab54ebbaaf2d2f1011720403f5942

See more details on using hashes here.

File details

Details for the file mizue-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: mizue-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for mizue-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 081e618f63e9106f7012dbaa249d5c6740546e069d22c356ac49e2b4d671ff50
MD5 b846bfbb86ac2c5f9f5dccc342e5b555
BLAKE2b-256 a3518d3836047c1582cbcc66db65751a62fc36a461d053133bc1ce5d46853067

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