py-print-extended 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of py-print-extended might be problematic. Click here for more details.
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "py-print-extended"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
description = "A package, that extends output posibilities. Similar to 'rich' in some point"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.9"
|
|
7
|
+
[build-system]
|
|
8
|
+
requires = ["hatchling >= 1.26"]
|
|
9
|
+
build-backend = "hatchling.build"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import time
|
|
2
|
+
import random
|
|
3
|
+
|
|
4
|
+
def print_with_speed(*args, speed_s: int, sep: str = " ", **kwargs):
|
|
5
|
+
chars = list(sep.join(args))
|
|
6
|
+
|
|
7
|
+
for char in chars:
|
|
8
|
+
print(char, end="")
|
|
9
|
+
time.sleep(speed_s)
|
|
10
|
+
|
|
11
|
+
def print_with_time(*args, time_s: int, sep: str = " "):
|
|
12
|
+
try:
|
|
13
|
+
speed_s = sep.join(args)/time_s
|
|
14
|
+
except ZeroDivisionError:
|
|
15
|
+
speed_s = 0
|
|
16
|
+
|
|
17
|
+
for char in list(sep.join(args)):
|
|
18
|
+
print(char, end="")
|
|
19
|
+
time.sleep(speed_s)
|
|
20
|
+
|
|
21
|
+
def print_random_words(words: list[str], cycles: int = 1, sep: str = " "):
|
|
22
|
+
for _ in cycles:
|
|
23
|
+
print(random.choice(words), sep=sep)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from typing import Literal, get_args
|
|
2
|
+
|
|
3
|
+
batchClr = "\033[Cm"
|
|
4
|
+
bashClr = "\e[Cm"
|
|
5
|
+
|
|
6
|
+
platforms = Literal[
|
|
7
|
+
"Windows", "Linux"
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
text_colors = Literal[
|
|
11
|
+
"black",
|
|
12
|
+
"red",
|
|
13
|
+
"green",
|
|
14
|
+
"yellow",
|
|
15
|
+
"blue",
|
|
16
|
+
"magenta",
|
|
17
|
+
"cyan",
|
|
18
|
+
"white",
|
|
19
|
+
"bright_black",
|
|
20
|
+
"bright_red",
|
|
21
|
+
"bright_green",
|
|
22
|
+
"bright_yellow",
|
|
23
|
+
"bright_blue",
|
|
24
|
+
"bright_magenta",
|
|
25
|
+
"bright_cyan",
|
|
26
|
+
"bright_white",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
colors: dict[int, list[str]] = {
|
|
30
|
+
0: ["30", "40"], # black
|
|
31
|
+
1: ["31", "41"], # red
|
|
32
|
+
2: ["32", "42"], # green
|
|
33
|
+
3: ["33", "43"], # yellow
|
|
34
|
+
4: ["34", "44"], # blue
|
|
35
|
+
5: ["35", "45"], # magenta
|
|
36
|
+
6: ["36", "46"], # cyan
|
|
37
|
+
7: ["37", "47"], # white
|
|
38
|
+
8: ["90", "100"], # bright_black
|
|
39
|
+
9: ["91", "101"], # bright_red
|
|
40
|
+
10: ["92", "102"], # bright_green
|
|
41
|
+
11: ["93", "103"], # bright_yellow
|
|
42
|
+
12: ["94", "104"], # bright_blue
|
|
43
|
+
13: ["95", "105"], # bright_magenta
|
|
44
|
+
14: ["96", "106"], # bright_cyan
|
|
45
|
+
15: ["97", "107"], # bright_white
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
def color(platform: platforms, color: text_colors, foreground: bool):
|
|
49
|
+
raw = ""
|
|
50
|
+
if platform == "Linux":
|
|
51
|
+
raw = bashClr
|
|
52
|
+
else: raw = batchClr
|
|
53
|
+
|
|
54
|
+
idx: int = -1
|
|
55
|
+
|
|
56
|
+
idx = 0 if foreground == True else idx = 1
|
|
57
|
+
|
|
58
|
+
clrs = get_args(text_colors)
|
|
59
|
+
return colors[clrs.index(color)][idx]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|