string_py package¶
Submodules¶
string_py.string_py module¶
- class string_py.string_py.Color[source]¶
Bases:
objectColor variations for prints
- basic = '\x1b[37m'¶
- bold = ('\x1b[1m',)¶
- error = ('\x1b[31m',)¶
- force = ('\x1b[0m',)¶
- reset = ('\x1b[0m',)¶
- underline = ('\x1b[4m',)¶
- class string_py.string_py.Format[source]¶
Bases:
objectFormat texts
- static align(values: dict[str, str])[source]¶
Align a text
- Parameters:
values – dict[str, str] Texts to align {“Left side”: “Right side”}
- Returns:
Returns a string with the key aligned left and the value right dependent from the keys
Examples¶
values = {"Username:": "John", "Register Date:": "01.01.2001"} Username: John Register Date: 01.01.2001
- static embed(title: str, description: str | None = None, url: str | None = None, fields: list[dict[str, str]] | None = None, footer: str | None = None, author: str | None = None, image: str | None = None)[source]¶
Create an embed
- Parameters:
title – str Title of the embed
description – str Description of the embed
url – str Url of the embed
fields – list[dict[str, str]] Fields of the embed
footer – str Footer of the embed
author – str Author of the embed
image – str Image of the embed
- Returns:
str
- static surround(values: str | list[str], all_: str | None = None, left: str = '│', top: str = '─', bottom: str = '─', top_left: str = '┌', top_right: str = '┐', bottom_left: str = '└', bottom_right: str = '┘') str[source]¶
Surround a text with chars
- Parameters:
bottom – Char to surround the bottom with
top – Char to surround the top with
- :param values:str
Text to surround
- Parameters:
all – Char to surround everything with (Overrides all other chars)
bottom_right – Char to surround the bottom right corner with
bottom_left – Char to surround the bottom left corner with
top_right – Char to surround the top right corner with
top_left – Char to surround the top left corner with
left – Char to surround the left side with
- Returns:
Returns a string with the text surrounded with certain chars
- class string_py.string_py.Printer(active: bool = True)[source]¶
Bases:
objectAdds new print methods to work with.
- Parameters:
active – True If set to False, no more prints are executed. Exception: force Parameter is set to True.
- async aio_slow(args: str, speed: float = 0.1, force: bool = False, error: bool = False) None[source]¶
Async slow print: Char after char gets printed in a certain speed
- Parameters:
args – str The text to print.
speed – 0.1 The speed in wich the chars will get printed out
force – False Set to True to print always, even if
activeis set to False.error – False Set to True to print always, even if
activeis set to False, gets highlighted with red color.
- slow(args: str, speed: float = 0.2, force: bool = False, error: bool = False) None[source]¶
Slow print: Char after char gets printed in a certain speed
- Parameters:
args – str The text to print.
speed – 0.1 The speed in wich the chars will get printed out
force – False Set to True to print always, even if
activeis set to False.error – False Set to True to print always, even if
activeis set to False, gets highlighted with red color.
- time(args: str, dt: bool = True, force: bool = False, error: bool = False) None[source]¶
Timestamp print: Print with the current day and time.
- Parameters:
args – str The text to print.
dt – True Set to False to turn off timestamp.
force – False Set to True to print always, even if
activeis set to False.error – False Set to True to print always, even if
activeis set to False, gets highlighted with red color.
- class string_py.string_py.Str(values: str | int)[source]¶
Bases:
strFunctions to work with strings
- Parameters:
values – str The value you want to work with
- first(length: int = 1, remove=False) str[source]¶
A simplification for getting/removing the first chars in a string
- Parameters:
length – The amount of chars
remove – If set to True removes length of
values
- generate(length: int | None = None, min_: int | None = None, max_: int | None = None) str[source]¶
Generate a random string out of
values- Parameters:
length – Generate with certain length
min – Generate with random length, max_ required
max – Generate with random length, min_ required
- Returns:
Returns random string out of
valueswith length out of parameters
- get_lower(chars: bool = True, index: bool = False) int | list[str] | dict[int, str][source]¶
Get how many lower chars are in
values- Parameters:
chars – True If set to True, returns a list of all lower chars If set to False, returns the number of lower chars
index – False If set to True, also returns the Indexes of lower chars (chars MUST be True)
- get_numeric(chars: bool = True, index: bool = False) int | list[str] | dict[int, str][source]¶
Get how many numeric chars are in
values- Parameters:
chars – True If set to True, returns a list of all numeric chars If set to False, returns the number of numeric chars
index – False If set to True, also returns the Indexes of numeric chars (chars MUST be True)
- get_punctuation(chars: bool = True, index: bool = False) int | list[str] | dict[int, str][source]¶
Get how many punctuation chars are in
values- Parameters:
chars – True If set to True, returns a list of all punctuation chars If set to False, returns the number of punctuation chars
index – False If set to True, also returns the Indexes of punctuation chars (chars MUST be True)
- get_upper(chars: bool = True, index: bool = False) int | list[str] | dict[int, str][source]¶
Get how many upper chars are in
values- Parameters:
chars – True If set to True, returns a list of all uppercase chars If set to False, returns the number of uppercase chars
index – False If set to True, also returns the Indexes of lower chars (chars MUST be True)
- last(length: int = 1, remove=False) str[source]¶
A simplification for getting/removing the last chars in a string
- Parameters:
length – The amount of chars
remove – If set to True removes length of
values