Skip to main content

Python library for text formatting on the command line.

PyPI version number Changelog Supported Python version License Download Count

Available Data

__version__

library version.

re_ansi_control_codes

Compiled regex pattern for ANSI control codes, including colors.

re_weburl

Compiled regex pattern for web URL’s – http, https, and naked domains like “example.com”

re_allurl

Compiled regex pattern to match all URL’s, including “mailto:foo@example.com”, “x-whatever://foo”, etc.

Answers

An Enum containing the possible query answers. Current contains YES, NO, QUIT, ALL, and NONE. YES and ALL are “truth-y” while NO, QUIT, and NONE are “false-y”.

Available Commands

length_no_ansi(mystring)

Takes a string, strips out the ANSI escape codes (used for colouring terminal output, etc.), and returns the length of the resulting string

centered (mystring, linewidth=None, fill=” “)

Takes a string, centres it, and pads it on both sides. Default linewidth is one less than the console width.

clock_on_right(mystring)

Takes a string, and prints it with the time right aligned

query_yes_no(question, default=”yes”)

Ask a yes/no question via raw_input() and return their answer.

  • “question” is a string that is presented to the user.

  • “default” is the presumed answer if the user just hits <Enter>. It must be “yes” (the default), “no” or None (meaning an answer is required of the user).

  • Returns one of Answer.YES or Answer.NO

query_yes_no_all(question, default=”yes”)

Ask a yes/no/all question via raw_input() and return their answer.

  • “question” is a string that is presented to the user.

  • “default” is the presumed answer if the user just hits <Enter>. It must be “yes” (the default), “no”, “all” or None (meaning an answer is required of the user).

  • Returns one of Answer.YES, Answer.NO, or Answer.ALL

def query_yes_quit(question, default=”quit”)

Ask a yes/quit question via raw_input() and return their answer.

  • “question” is a string that is presented to the user.

  • “default” is the presumed answer if the user just hits <Enter>. It must be “yes” (the default), “quit” or None (meaning an answer is required of the user).

  • Returns one of Answer.YES or Answer.QUIT

query_yes_no_all_none(question, default=”yes”)

Ask a yes/no/all/none question via raw_input() and return their answer.

  • “question” is a string that is presented to the user.

  • “default” is the presumed answer if the user just hits <Enter>. It must be “yes” (the default), “no”, “all”, “none” (i.e. the string) or None (meaning an answer is required of the user).

  • Returns one of Answer.YES, Answer.NO, Answer.ALL, or Answer.NONE

wait(sec)

Prints a timer with the format 0:00 to the console, and then clears the line when the timer is done.

title(mytitle)

Takes mytitle, centers it, and prints it in yellow letters on a blue background.

subtitle(mysubtitle)

Takes mysubtitle, centers it, and prints it in bright (white) letters on a normal (black) background.

rainbow_print(text, offset=0)

Prints out text in a cycle of rainbow-esque colors!

progressbar (class)

This class is used to create and then update a ‘progress bar’, like:

[================>                                                    ] 17 / 70

progressbar(current=0, maximum=100, bar_color=colorama.Fore.GREEN)

Creates a progress bar class. Prints the progress bar.

progressbar.update(currently=None)

Updates the value of the progress bar and prints it.

progressbar.reset()

Sets the value of the progress bar to 0 (zero) and prints it.

Code

The code is available at https://github.com/MinchinWeb/minchin.text

Contributions are welcome!

Tests

Located in the test folder. Each is a “visual test”, so they need to be run and the output manually examined.

License

The code is licensed under the MIT license. See that attached LICENSE file.

Metadata

Release files for minchin.text 7.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for minchin.text 7.0.0
File Size Uploaded
minchin_text-7.0.0.tar.gz 12.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for minchin.text 7.0.0
File Interpreter ABI Platform
minchin_text-7.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.3 kB

Release files / minchin_text-7.0.0.tar.gz

Download URL minchin_text-7.0.0.tar.gz
Size 12.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8b7791afe9ceebff03f6c44c51178e4d2ced0d72d72646b44ea566e3ae36190e
BLAKE2b-256 checksum
How to use checksums
d7253485653a25ac71e3f598350f4caa884ca366d0d22b224dc6e3994d6520e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.0

Release files / minchin_text-7.0.0-py3-none-any.whl

Download URL minchin_text-7.0.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c7d247c982753b2d9ce515d71d8e5bc7ed108fffc41a4167b8ae585cefd984a
BLAKE2b-256 checksum
How to use checksums
9189208fcd4ef7edef644cbe5be6bd268367836d92054c3fb2f7885efb548c8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.0

Release history Release notifications | RSS feed

This release

7.0.0 This release

2 release files

6.1.0

2 release files

6.0.2

2 release files

6.0.1

2 release files

6.0.0

2 release files

5.1.1

2 release files

5.1.0

2 release files

5.0.1

3 release files

5.0.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page