Lightweight terminal utilities
Project description
tooly
Lightweight terminal utilities for Python developers.
Installation
pip install tooly-dev
Usage
import tooly
import time
colors = tooly.ColorSystem() #? recommended
wait_time = 0.5
print(colors.info("Welcome to Tooly!")) #* Color example
tooly.typewrite(colors.info("Example text"), delay=0.05) #* Typewrite example
with tooly.measure("Example measure"):
#? Do something
time.sleep(wait_time)
with tooly.spinner("Example spinner", done_msg="Exaple spinner done"):
#? Do something
time.sleep(wait_time)
#* Highlight example
text = "Some interesting text with keywords"
print(colors.highlight(text, ["keywords", "text"], "yellow")) #? text, keywords, color
#* Indent example
#? You can use indent for file tree for example
print(colors.indent("Example folder/", 0))
print(colors.indent("Example python file", 1))
print(colors.indent("Example readme file", 1))
print(colors.indent("Example subfolder/", 1))
print(colors.indent("howtodoerrors.txt", 2))
print(colors.indent("Example file", 0))
#* Diff feature examples
# word mode sql example
sql_before = "SELECT id, name FROM users WHERE active = 1"
sql_after = "SELECT id, email FROM users WHERE active = 1 LIMIT 100"
print(tooly.diff_highlight(sql_before, sql_after, tooly.DiffMode.WORD))
# char mode url example
url_before = "https://api.example.com/v1/users/42"
url_after = "https://api.example.com/v2/users/42/profile"
print(tooly.diff_highlight(url_before, url_after, tooly.DiffMode.CHAR))
# line mode config example
cfg_before = """
host = localhost
port = 5432
debug = true
workers = 2
"""
cfg_after = """
host = example.com
port = 5432
debug = false
workers = 8
timeout = 30
"""
print(tooly.diff_highlight(cfg_before, cfg_after, tooly.DiffMode.LINE, context_lines=1))
#* Validator example
"""
Methods:
str.isalpha() - only letters
str.isdigit() - only dights
str.isnumeric() - only dights (including unicode)
str.isalnum() - digits and letters
str.islower() - only lower case
str.isupper() - only upper case
str.istitle() - every word starts with a capital
str.startswith(prefix) - starts with a prefix
str.endswith(suffix) - ends with a suffix
str.isprintable() - only printable characters
str.isascii() - only ASCII characters
"""
tooly.userinput("Enter your name: ", validator=lambda name: name.isalpha(), error_msg="Invalid name. Try again.")
tooly.userinput("Enter your age: ", validator=lambda name: name.isdigit(), error_msg="Invalid age. Try again.")
#* Recorder example
with tooly.recorder("example_session.log"):
print("Recorder example...")
name = tooly.userinput("Enter your name: ", validator=lambda name: name.isalpha(), error_msg="Invalid name. Try again.")
print(f"Hello, {name}!")
License
MIT
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
tooly_dev-1.2.0.tar.gz
(6.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tooly_dev-1.2.0.tar.gz.
File metadata
- Download URL: tooly_dev-1.2.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9507e5d02c3038cf8eeb5c5177270be1e9d3bcb7c828860d9e2837c4d3a3985b
|
|
| MD5 |
64140245f744fcea760cf633107c28b0
|
|
| BLAKE2b-256 |
dac74998a2388a2c8374721c72c3bf1dec2aa0f0f2d1890f5b0e1f2dd3f05a2b
|
File details
Details for the file tooly_dev-1.2.0-py3-none-any.whl.
File metadata
- Download URL: tooly_dev-1.2.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9239497ce59fd25f08a7cc61ee79c37538eebd5bb9aef4522bdbff1fd5091634
|
|
| MD5 |
49db0c20429faea7cc39f12fc8c3d1ed
|
|
| BLAKE2b-256 |
3410a974da79b926207de5775dd858987bef5c63ebf3423d694d0b4e94bdcb49
|