Python library for text formatting on the command line.
library version.
Compiled regex pattern for ANSI control codes, including colors.
Compiled regex pattern for web URL's -- http, https, and naked domains like "example.com"
Compiled regex pattern to match all URL's, including "mailto:foo@example.com", "x-whatever://foo", etc.
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".
Takes a string, strips out the ANSI escape codes (used for colouring terminal output, etc.), and returns the length of the resulting string
Takes a string, centres it, and pads it on both sides. Default linewidth
is one less than the console width.
Takes a string, and prints it with the time right aligned
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
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
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
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
Prints a timer with the format 0:00 to the console, and then clears the line when the timer is done.
Takes mytitle
, centers it, and prints it in yellow letters on a blue background.
Takes mysubtitle
, centers it, and prints it in bright (white) letters on a normal (black) background.
Prints out text
in a cycle of rainbow-esque colors!
This class is used to create and then update a 'progress bar', like:
[================> ] 17 / 70
Creates a progress bar class. Prints the progress bar.
Updates the value of the progress bar and prints it.
Sets the value of the progress bar to 0 (zero) and prints it.
The code is available at https://github.com/MinchinWeb/minchin.text
Contributions are welcome!
Located in the test folder. Each is a "visual test", so they need to be run and the output manually examined.
The code is licensed under the MIT license. See that attached LICENSE file.