Useful methods for working in the terminal!
Project description
Iridis
This library provides functions to print styled text in the console, with support for color-coded messages and rainbow text effects.
Color Enum
The Color enum defines various color codes that can be used with the functions below.
from enum import Enum
class Color(Enum):
RED = "\033[91m"
GREEN = "\033[92m"
YELLOW = "\033[93m"
BLUE = "\033[94m"
PURPLE = "\033[95m"
# Additional colors available (e.g., BRIGHT, BG colors)
Functions
print_with_color(*values: object, color: Color)
Prints the given values in the specified color.
- values: Objects to print.
- color:
Colorenum specifying the text color.
Example
print_with_color("Hello, World!", color=Color.BLUE)
print_error(*values: object)
Prints the values in red to indicate an error.
- values: Objects representing the error message.
Example
print_error("This is an error message.")
print_title(*values: object)
Prints the values in green to indicate a title or header.
- values: Objects representing the title text.
Example
print_title("Welcome to the Application")
print_rainbow(*values: object)
Prints the values with a rainbow color effect.
- values: Objects to print with each character in a different color.
Example
print_rainbow("This text is in rainbow colors!")
get_number_from_user(input_text: str, error_message: str, conditions: list) -> float
Prompts the user for a number and validates it against optional conditions.
- input_text: Prompt text (default: "Vložte číslo:").
- error_message: Error message shown if input is invalid (default: "Špatný vstup, zkuste znova!").
- conditions: List of boolean lambda conditions to validate the input.
Example
get_number_from_user("Enter a number: ", "Invalid input!", conditions=[lambda x: x > 0])
get_string_from_user(input_text: str, error_message: str, conditions: list) -> str
Prompts the user to input a string and validates it against specified conditions.
- input_text: Prompt text for the user.
- error_message: Error message shown if input is invalid (default: "Špatný vstup, zkuste znova!").
- conditions: A list of callable conditions that take a string and return a boolean.
Example
get_string_from_user(
"Enter your name: ",
"Invalid name!",
conditions=[is_not_empty, is_alpha_only]
)
String Validation Functions
These utility functions validate string inputs:
is_not_empty(string: str) -> bool: Checks if the string is not empty.is_alpha_only(string: str) -> bool: Ensures the string contains only alphabetic characters.has_digits(string: str) -> bool: ReturnsTrueif the string contains any digits.has_no_digits(string: str) -> bool: Ensures the string has no digits.has_special_characters(string: str) -> bool: Checks if the string contains any special characters.has_no_special_characters(string: str) -> bool: Ensures the string has no special characters.is_valid_utf8(string: str) -> bool: Checks if the string contains only valid UTF-8 characters.
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
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 iridis-0.2.3.tar.gz.
File metadata
- Download URL: iridis-0.2.3.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd91ef62c3bef633c68210426abd43fdd880f419d22a16281c9846e4a4318f8e
|
|
| MD5 |
ee362bb16aa0ce6969e99af4f4c85191
|
|
| BLAKE2b-256 |
bbd265af27d3ddfbb69194415ab20f28eee9ba9f01f0681af22d1f79e3f285d4
|
File details
Details for the file iridis-0.2.3-py3-none-any.whl.
File metadata
- Download URL: iridis-0.2.3-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c578661ddcecba2f4be2417d0dd5afd2f17ada406612efbf17cb89480ed1bf5
|
|
| MD5 |
f08af63787e751be813e39fb4aa1929c
|
|
| BLAKE2b-256 |
4045c94b0c807753c6f60f4ecf70cc29a3caa04343073b0f453c235d5c5efbb9
|