Helpers for command line interaces (CLI) in terminal
Project description
Read the Docs: http://buzio.readthedocs.io/
Source Code: https://github.com/chrismaille/buzio
Buzio is a python library tool for printing formatted text in terminal, similar to termcolor or colored.
Installing Buzio
Install Buzio using the command:
$ pip install buzio
Importing the Library
from buzio import console, formatStr
The console is a instance of the Console class initialized with default color themes. You can also import the class and instantiate with your own settings (See the :doc:reference for more info)
The formatStr is also a instance of the Console class too, but instead of printing in terminal the message, this instance just return the formatted text.
The default color themes
Method |
Text Color |
---|---|
console.box |
Fore.CYAN |
console.error |
Fore.RED |
console.info |
Fore.CYAN |
console.section |
Fore.LIGHTYELLOW_EX |
console.success |
Fore.GREEN |
console.warning |
Fore.YELLOW |
These colors are based in colorama constants.
Generate fancy formats
“Section” example 1:
from buzio import console
console.section("First Section")
Terminal output:
$ >> First Section $ ----------------
Humanize Python objects
Buzio can automatically humanize any python object for printing in terminal:
from datetime import datetime, timedelta
from buzio import console
today = datetime.now()
yesterday = today - timedelta(days=1)
my_dict = {
"start day": yesterday,
"end day": today
}
console.box(my_dict, date_format="%a, %b-%d-%Y")
The output on terminal will be (in blue color):
$ ********************************* $ * * $ * start day: Thu, Feb-01-2018 * $ * end day: Fri, Feb-02-2018 * $ * * $ *********************************
Ask for Input data
You can use Buzio to automatically generate “choose” and “select” questions, based on Python objects:
“Choose” example:
from buzio import console
my_choices = [
"Orange",
"Apple",
"Potato"
]
console.choose(my_choices)
Terminal output:
$ 1. Orange $ 2. Apple $ 3. Potato $ $ Select (1-3): ?
Run terminal commands
You can use Buzio to run terminal commands (using Python subprocess) and get the stdout result:
>>> from buzio import console >>> ret = console.run("echo HelloWorld!", get_stdout=True, verbose=True) Cmd: echo HelloWorld! >>> print(ret) HelloWorld!
Further reading
Please check full documentation in http://buzio.readthedocs.io/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file buzio-1.1.2.tar.gz
.
File metadata
- Download URL: buzio-1.1.2.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dedc86f2783f7ac285322d970c4db96b044136d7a685ade33b53cd89ed215e6f |
|
MD5 | bb323200404e2849588a24bdf51ba45d |
|
BLAKE2b-256 | 26eb574ed36c5b6bd28b635b9d792210016c28817dee0ae3bd641773db37a6b2 |
File details
Details for the file buzio-1.1.2-py2.py3-none-any.whl
.
File metadata
- Download URL: buzio-1.1.2-py2.py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4461b3f7aa5e7535a9a0a99d1280ea8a85fdf3f0f931f596c96d7cf40dd54a5 |
|
MD5 | aaadb6e4b47ad1808f8c2af781b58ed1 |
|
BLAKE2b-256 | 1134f17c55470ae279729526bcb30e2b47927f5afcfa092ce4ebd08605ac5679 |