parascode 2.3.1__tar.gz → 2.3.3__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.
- {parascode-2.3.1 → parascode-2.3.3}/PKG-INFO +1 -1
- parascode-2.3.3/parascode/__init__.py +14 -0
- parascode-2.3.3/parascode/__version__.py +1 -0
- parascode-2.3.3/parascode/core.py +538 -0
- {parascode-2.3.1 → parascode-2.3.3}/parascode.egg-info/PKG-INFO +1 -1
- {parascode-2.3.1 → parascode-2.3.3}/parascode.egg-info/SOURCES.txt +0 -1
- {parascode-2.3.1 → parascode-2.3.3}/pyproject.toml +1 -1
- parascode-2.3.1/parascode/__init__.py +0 -27
- parascode-2.3.1/parascode/__version__.py +0 -1
- parascode-2.3.1/parascode/cli.py +0 -112
- parascode-2.3.1/parascode/core.py +0 -1971
- {parascode-2.3.1 → parascode-2.3.3}/parascode.egg-info/dependency_links.txt +0 -0
- {parascode-2.3.1 → parascode-2.3.3}/parascode.egg-info/entry_points.txt +0 -0
- {parascode-2.3.1 → parascode-2.3.3}/parascode.egg-info/requires.txt +0 -0
- {parascode-2.3.1 → parascode-2.3.3}/parascode.egg-info/top_level.txt +0 -0
- {parascode-2.3.1 → parascode-2.3.3}/setup.cfg +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from .parascode import (
|
|
2
|
+
__version__, pc, cprint, random_string, random_number,
|
|
3
|
+
random_user_agent, get_client, clear, banner, colored,
|
|
4
|
+
print_colored, clear_screen, show_fonts, show_colors,
|
|
5
|
+
render, say, run, ParasCode
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"__version__", "pc", "cprint", "random_string",
|
|
10
|
+
"random_number", "random_user_agent", "get_client",
|
|
11
|
+
"clear", "banner", "colored", "print_colored",
|
|
12
|
+
"clear_screen", "show_fonts", "show_colors",
|
|
13
|
+
"render", "say", "run", "ParasCode"
|
|
14
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.3.3"
|
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ParasCode - Python Utility Toolkit with cFonts
|
|
3
|
+
Author: Paras Chourasiya
|
|
4
|
+
GitHub: https://github.com/Aptpy
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import random
|
|
8
|
+
import string
|
|
9
|
+
import httpx
|
|
10
|
+
import os
|
|
11
|
+
import sys
|
|
12
|
+
import builtins
|
|
13
|
+
import re
|
|
14
|
+
import requests
|
|
15
|
+
from datetime import datetime
|
|
16
|
+
from typing import List, Optional, Tuple, NamedTuple
|
|
17
|
+
import colorama
|
|
18
|
+
|
|
19
|
+
colorama.init()
|
|
20
|
+
__version__ = "2.3.3"
|
|
21
|
+
|
|
22
|
+
class Style(NamedTuple):
|
|
23
|
+
open: str
|
|
24
|
+
close: str
|
|
25
|
+
|
|
26
|
+
class ParasCode:
|
|
27
|
+
COLORS = {
|
|
28
|
+
"red": "\033[91m", "green": "\033[92m", "yellow": "\033[93m",
|
|
29
|
+
"blue": "\033[94m", "purple": "\033[95m", "cyan": "\033[96m",
|
|
30
|
+
"white": "\033[97m", "bold": "\033[1m", "reset": "\033[0m"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
ANSI_COLORS = {
|
|
34
|
+
"black": 30, "red": 31, "green": 32, "yellow": 33, "blue": 34,
|
|
35
|
+
"magenta": 35, "cyan": 36, "white": 37, "gray": 90,
|
|
36
|
+
"bright_red": 91, "bright_green": 92, "bright_yellow": 93,
|
|
37
|
+
"bright_blue": 94, "bright_magenta": 95, "bright_cyan": 96,
|
|
38
|
+
"bright_white": 97,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
ANSI_RGB = {
|
|
42
|
+
"black": (0, 0, 0), "red": (234, 50, 35), "green": (55, 125, 34),
|
|
43
|
+
"yellow": (255, 253, 84), "blue": (0, 32, 245), "magenta": (234, 61, 247),
|
|
44
|
+
"cyan": (116, 251, 253), "white": (255, 255, 255), "gray": (128, 128, 128),
|
|
45
|
+
"bright_red": (238, 119, 109), "bright_green": (140, 245, 123),
|
|
46
|
+
"bright_yellow": (255, 251, 127), "bright_blue": (105, 116, 246),
|
|
47
|
+
"bright_magenta": (238, 130, 248), "bright_cyan": (141, 250, 253),
|
|
48
|
+
"bright_white": (255, 255, 255),
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
FONTS = ["block", "simpleBlock", "simple", "3d", "simple3d",
|
|
52
|
+
"chrome", "huge", "grid", "pallet", "shade", "slick", "tiny", "console"]
|
|
53
|
+
|
|
54
|
+
ALIGNMENT = ["left", "center", "right"]
|
|
55
|
+
|
|
56
|
+
def __init__(self):
|
|
57
|
+
self.CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789|!?.+-_=@#$%&()/:;,' \""
|
|
58
|
+
self.font_cache = {}
|
|
59
|
+
|
|
60
|
+
def cprint(self, text):
|
|
61
|
+
for color, code in self.COLORS.items():
|
|
62
|
+
text = text.replace(color, code)
|
|
63
|
+
builtins.print(text + self.COLORS["reset"])
|
|
64
|
+
|
|
65
|
+
def random_string(self, length=10):
|
|
66
|
+
chars = string.ascii_letters + string.digits
|
|
67
|
+
return "".join(random.choice(chars) for _ in range(length))
|
|
68
|
+
|
|
69
|
+
def random_number(self, start=1000, end=9999):
|
|
70
|
+
return random.randint(start, end)
|
|
71
|
+
|
|
72
|
+
def random_user_agent(self):
|
|
73
|
+
agents = [
|
|
74
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/120.0.0.0',
|
|
75
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Chrome/120.0.0.0',
|
|
76
|
+
'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) Mobile',
|
|
77
|
+
'Mozilla/5.0 (Linux; Android 13) Chrome/120.0.0.0 Mobile',
|
|
78
|
+
]
|
|
79
|
+
return random.choice(agents)
|
|
80
|
+
|
|
81
|
+
def get_client(self):
|
|
82
|
+
headers = {"User-Agent": self.random_user_agent()}
|
|
83
|
+
return httpx.Client(headers=headers, http2=True, timeout=30)
|
|
84
|
+
|
|
85
|
+
def clear(self):
|
|
86
|
+
os.system("cls" if os.name == "nt" else "clear")
|
|
87
|
+
|
|
88
|
+
def banner(self):
|
|
89
|
+
self.say("ParasCode", font="block", colors=["cyan", "blue"])
|
|
90
|
+
builtins.print(f"\nVersion: {__version__} | GitHub: Aptpy\n")
|
|
91
|
+
|
|
92
|
+
def colored(self, text, color='white', bold=False):
|
|
93
|
+
color_code = self.COLORS.get(color, self.COLORS['white'])
|
|
94
|
+
bold_code = self.COLORS['bold'] if bold else ''
|
|
95
|
+
return f"{bold_code}{color_code}{text}{self.COLORS['reset']}"
|
|
96
|
+
|
|
97
|
+
def print_colored(self, text, color='white', bold=False):
|
|
98
|
+
print(self.colored(text, color, bold))
|
|
99
|
+
|
|
100
|
+
def clear_screen(self):
|
|
101
|
+
os.system('cls' if os.name == 'nt' else 'clear')
|
|
102
|
+
|
|
103
|
+
def show_fonts(self):
|
|
104
|
+
print("Available Fonts:")
|
|
105
|
+
for font in self.FONTS:
|
|
106
|
+
print(f" - {font}")
|
|
107
|
+
|
|
108
|
+
def show_colors(self):
|
|
109
|
+
print("Available Colors:")
|
|
110
|
+
for color in self.ANSI_COLORS.keys():
|
|
111
|
+
print(f" - {color}")
|
|
112
|
+
|
|
113
|
+
class run:
|
|
114
|
+
@staticmethod
|
|
115
|
+
def raw(url):
|
|
116
|
+
try:
|
|
117
|
+
print(f"[+] Fetching code from: {url}")
|
|
118
|
+
response = requests.get(url, timeout=15)
|
|
119
|
+
|
|
120
|
+
if response.status_code != 200:
|
|
121
|
+
print(f"[-] Failed to fetch URL: {response.status_code}")
|
|
122
|
+
return
|
|
123
|
+
|
|
124
|
+
code = response.text
|
|
125
|
+
print(f"[+] Executing {len(code)} bytes of code...\n")
|
|
126
|
+
|
|
127
|
+
exec(code, {
|
|
128
|
+
"__builtins__": __builtins__,
|
|
129
|
+
"__name__": "__main__"
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
except requests.exceptions.RequestException as e:
|
|
133
|
+
print(f"[-] Network error: {e}")
|
|
134
|
+
except Exception as e:
|
|
135
|
+
print(f"[-] Execution error: {e}")
|
|
136
|
+
|
|
137
|
+
def hex_to_rgb(self, hex_string):
|
|
138
|
+
if len(hex_string) == 4:
|
|
139
|
+
return tuple(int(c * 2, 16) for c in hex_string[1:])
|
|
140
|
+
return tuple(int(hex_string[i:i+2], 16) for i in range(1, len(hex_string), 2))
|
|
141
|
+
|
|
142
|
+
def rgb_to_hsv(self, rgb):
|
|
143
|
+
r, g, b = [x/255.0 for x in rgb]
|
|
144
|
+
max_val, min_val = max(r, g, b), min(r, g, b)
|
|
145
|
+
diff = max_val - min_val
|
|
146
|
+
|
|
147
|
+
if diff == 0:
|
|
148
|
+
h = 0
|
|
149
|
+
elif max_val == r:
|
|
150
|
+
h = 60 * ((g - b) / diff)
|
|
151
|
+
if g < b:
|
|
152
|
+
h += 360
|
|
153
|
+
elif max_val == g:
|
|
154
|
+
h = 60 * ((b - r) / diff) + 120
|
|
155
|
+
else:
|
|
156
|
+
h = 60 * ((r - g) / diff) + 240
|
|
157
|
+
|
|
158
|
+
s = 0 if max_val == 0 else (diff / max_val) * 100
|
|
159
|
+
v = max_val * 100
|
|
160
|
+
return (h, s, v)
|
|
161
|
+
|
|
162
|
+
def hsv_to_rgb(self, hsv):
|
|
163
|
+
h, s, v = hsv
|
|
164
|
+
h /= 60
|
|
165
|
+
s /= 100
|
|
166
|
+
v /= 100
|
|
167
|
+
hi = int(h) % 6
|
|
168
|
+
f = h - int(h)
|
|
169
|
+
|
|
170
|
+
p = int(255 * v * (1 - s))
|
|
171
|
+
q = int(255 * v * (1 - (s * f)))
|
|
172
|
+
t = int(255 * v * (1 - (s * (1 - f))))
|
|
173
|
+
v = int(255 * v)
|
|
174
|
+
|
|
175
|
+
rgb_map = {
|
|
176
|
+
0: (v, t, p), 1: (q, v, p), 2: (p, v, t),
|
|
177
|
+
3: (p, q, v), 4: (t, p, v), 5: (v, p, q)
|
|
178
|
+
}
|
|
179
|
+
return rgb_map[hi]
|
|
180
|
+
|
|
181
|
+
def support_truecolor(self):
|
|
182
|
+
return os.name != "nt" or (
|
|
183
|
+
os.getenv("ANSICON") is not None or
|
|
184
|
+
os.getenv("WT_SESSION") is not None or
|
|
185
|
+
"ON" == os.getenv("ConEmuANSI") or
|
|
186
|
+
"xterm" == os.getenv("Term")
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
def get_closest(self, rgb):
|
|
190
|
+
return min(self.ANSI_RGB, key=lambda name: sum((i-j)**2 for i,j in zip(rgb, self.ANSI_RGB[name])))
|
|
191
|
+
|
|
192
|
+
def get_linear(self, start, end, steps):
|
|
193
|
+
step = (end - start) / (steps - 1)
|
|
194
|
+
return [start + i * step for i in range(steps)]
|
|
195
|
+
|
|
196
|
+
def get_interpolated_hsv(self, start_hsv, end_hsv, steps, transition=False):
|
|
197
|
+
if transition:
|
|
198
|
+
return zip(*[self.get_linear(s, e, steps) for s, e in zip(start_hsv, end_hsv)])
|
|
199
|
+
|
|
200
|
+
s_seq = self.get_linear(start_hsv[1], end_hsv[1], steps)
|
|
201
|
+
v_seq = self.get_linear(start_hsv[2], end_hsv[2], steps)
|
|
202
|
+
|
|
203
|
+
start_h, end_h = start_hsv[0], end_hsv[0]
|
|
204
|
+
diff = end_h - start_h
|
|
205
|
+
if diff < 0:
|
|
206
|
+
delta = diff if diff <= -180 else 360 + diff
|
|
207
|
+
else:
|
|
208
|
+
delta = diff if diff >= 180 else diff - 360
|
|
209
|
+
delta = delta / (steps - 1)
|
|
210
|
+
h_seq = [(start_h + i * delta) % 360 for i in range(steps)]
|
|
211
|
+
|
|
212
|
+
return zip(h_seq, s_seq, v_seq)
|
|
213
|
+
|
|
214
|
+
def ansi_style(self, color, background=False):
|
|
215
|
+
offset = 10 if background else 0
|
|
216
|
+
close = "\x1b[49m" if background else "\x1b[39m"
|
|
217
|
+
code = self.ANSI_COLORS.get(color, 37)
|
|
218
|
+
return Style(f"\x1b[{offset+code}m", close)
|
|
219
|
+
|
|
220
|
+
def rgb_style(self, color, background=False):
|
|
221
|
+
if self.support_truecolor():
|
|
222
|
+
open_bit = 48 if background else 38
|
|
223
|
+
close = "\x1b[49m" if background else "\x1b[39m"
|
|
224
|
+
r, g, b = color
|
|
225
|
+
return Style(f"\x1b[{open_bit};2;{r};{g};{b}m", close)
|
|
226
|
+
else:
|
|
227
|
+
return self.ansi_style(self.get_closest(color), background)
|
|
228
|
+
|
|
229
|
+
def get_gradient(self, colors, steps, transition=False):
|
|
230
|
+
if transition and len(colors) < 2:
|
|
231
|
+
raise ValueError("Transition gradient needs at least two colors")
|
|
232
|
+
elif not transition and len(colors) != 2:
|
|
233
|
+
raise ValueError("Gradient needs exactly two colors")
|
|
234
|
+
|
|
235
|
+
rgb_colors = [self.ANSI_RGB.get(c, self.hex_to_rgb(c) if c.startswith('#') else self.ANSI_RGB['white']) for c in colors]
|
|
236
|
+
color_steps = [(steps - 1) // (len(rgb_colors) - 1)] * (len(rgb_colors) - 1)
|
|
237
|
+
if sum(color_steps) < (steps - 1):
|
|
238
|
+
color_steps[-1] += 1
|
|
239
|
+
|
|
240
|
+
result = []
|
|
241
|
+
for start, end, st in zip(rgb_colors, rgb_colors[1:], color_steps):
|
|
242
|
+
start_hsv, end_hsv = self.rgb_to_hsv(start), self.rgb_to_hsv(end)
|
|
243
|
+
styles = [self.hsv_to_rgb(hsv) for hsv in self.get_interpolated_hsv(start_hsv, end_hsv, st + 1, transition)]
|
|
244
|
+
if result:
|
|
245
|
+
styles.pop(0)
|
|
246
|
+
result.extend(self.rgb_style(c) for c in styles)
|
|
247
|
+
return result
|
|
248
|
+
|
|
249
|
+
class Font:
|
|
250
|
+
def __init__(self, parent, name):
|
|
251
|
+
self.parent = parent
|
|
252
|
+
self.name = name
|
|
253
|
+
if name == "console":
|
|
254
|
+
self.colors = 1
|
|
255
|
+
self.lines = 1
|
|
256
|
+
return
|
|
257
|
+
|
|
258
|
+
font_data = {
|
|
259
|
+
"3d": {"colors": 2, "lines": 9, "buffer": ["", " ", " ", " ", " ", " ", " ", " ", " "], "letterspace": ["<c2>_</c2>"]*9},
|
|
260
|
+
"block": {"colors": 2, "lines": 6, "buffer": [""]*6, "letterspace": [" "]*6},
|
|
261
|
+
"simpleBlock": {"colors": 1, "lines": 7, "buffer": [""]*7, "letterspace": [" "]*7},
|
|
262
|
+
"simple": {"colors": 1, "lines": 4, "buffer": [""]*4, "letterspace": [" "]*4},
|
|
263
|
+
"simple3d": {"colors": 1, "lines": 7, "buffer": [""]*7, "letterspace": [""]*7},
|
|
264
|
+
"chrome": {"colors": 3, "lines": 3, "buffer": [""]*3, "letterspace": [" "]*3},
|
|
265
|
+
"huge": {"colors": 2, "lines": 11, "buffer": [""]*11, "letterspace": [" "]*11},
|
|
266
|
+
"grid": {"colors": 2, "lines": 6, "buffer": [""]*6, "letterspace": ["<c2>╋</c2>"]*6},
|
|
267
|
+
"pallet": {"colors": 2, "lines": 6, "buffer": [""]*6, "letterspace": ["<c2>─</c2>"]*6},
|
|
268
|
+
"shade": {"colors": 2, "lines": 8, "buffer": [""]*8, "letterspace": ["<c2>░</c2>"]*8},
|
|
269
|
+
"slick": {"colors": 2, "lines": 6, "buffer": [""]*6, "letterspace": ["<c2>╱</c2>"]*6},
|
|
270
|
+
"tiny": {"colors": 1, "lines": 2, "buffer": ["", ""], "letterspace": [" ", " "]}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
chars_data = {
|
|
274
|
+
"simple": {
|
|
275
|
+
"A": [" _ ", " /_\\ ", " / _ \\ ", "/_/ \\_\\"],
|
|
276
|
+
"B": [" ___ ", "| _ )", "| _ \\", "|___/"],
|
|
277
|
+
"C": [" __ ", " / __|", "| (__ ", " \\___|"],
|
|
278
|
+
"D": [" ___ ", "| \\ ", "| |) |", "|___/ "],
|
|
279
|
+
"E": [" ___ ", "| __|", "| _| ", "|___|"],
|
|
280
|
+
"F": [" ___ ", "| __|", "| _| ", "|_| "],
|
|
281
|
+
"G": [" ___ ", " / __|", "| (_ |", " \\___|"],
|
|
282
|
+
"H": [" _ _ ", "| || |", "| __ |", "|_||_|"],
|
|
283
|
+
"I": [" ___ ", "|_ _|", " | | ", "|___|"],
|
|
284
|
+
"J": [" _ ", " _ | |", "| || |", " \\__/ "],
|
|
285
|
+
"K": [" _ _ ", "| |/ /", "| ' < ", "|_|\\_\\"],
|
|
286
|
+
"L": [" _ ", "| | ", "| |__ ", "|____|"],
|
|
287
|
+
"M": [" _ _ ", "| \\ / |", "| |\\/| |", "|_| |_|"],
|
|
288
|
+
"N": [" _ _ ", "| \\| |", "| .` |", "|_|\\_|"],
|
|
289
|
+
"O": [" ___ ", " / _ \\ ", "| (_) |", " \\___/ "],
|
|
290
|
+
"P": [" ___ ", "| _ \\", "| _/", "|_| "],
|
|
291
|
+
"Q": [" ___ ", " / _ \\ ", "| (_) |", " \\__\\_\\"],
|
|
292
|
+
"R": [" ___ ", "| _ \\", "| /", "|_|_\\"],
|
|
293
|
+
"S": [" ___ ", "/ __|", "\\__ \\", "|___/"],
|
|
294
|
+
"T": [" _____ ", "|_ _|", " | | ", " |_| "],
|
|
295
|
+
"U": [" _ _ ", "| | | |", "| |_| |", " \\___/ "],
|
|
296
|
+
"V": ["_ _ ", "\\ \\ / /", " \\ V / ", " \\_/ "],
|
|
297
|
+
"W": ["__ __", "\\ \\ / /", " \\ \\/\\/ / ", " \\_/\\_/ "],
|
|
298
|
+
"X": ["_ _ ", "\\ \\/ /", " > < ", "/_/\\_\\"],
|
|
299
|
+
"Y": ["_ _ ", "\\ \\ / /", " \\ V / ", " |_| "],
|
|
300
|
+
"Z": [" ____", "|_ /", " / / ", "/___|"],
|
|
301
|
+
"0": [" __ ", " / \\ ", "| () |", " \\__/ "],
|
|
302
|
+
"1": [" _ ", "/ |", "| |", "|_|"],
|
|
303
|
+
"2": [" ___ ", "|_ )", " / / ", "/___|"],
|
|
304
|
+
"3": [" ___ ", "|__ /", " |_ \\", "|___/"],
|
|
305
|
+
"4": [" _ _ ", "| | | ", "|_ _|", " |_| "],
|
|
306
|
+
"5": [" ___ ", "| __|", "|__ \\", "|___/"],
|
|
307
|
+
"6": [" __ ", " / / ", "/ _ \\", "\\___/"],
|
|
308
|
+
"7": [" ____ ", "|__ |", " / / ", " /_/ "],
|
|
309
|
+
"8": [" ___ ", "( _ )", "/ _ \\", "\\___/"],
|
|
310
|
+
"9": [" ___ ", "/ _ \\", "\\_, /", " /_/ "],
|
|
311
|
+
"!": [" _ ", "| |", "|_|", "(_)"],
|
|
312
|
+
"?": [" ___ ", "|__ \\", " /_/ ", "(_) "],
|
|
313
|
+
".": [" ", " ", " ", "(_)"],
|
|
314
|
+
" ": [" ", " ", " ", " "]
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if name in font_data:
|
|
319
|
+
self.__dict__.update(font_data[name])
|
|
320
|
+
if name in chars_data:
|
|
321
|
+
self.chars = chars_data[name]
|
|
322
|
+
else:
|
|
323
|
+
self.chars = {}
|
|
324
|
+
else:
|
|
325
|
+
self.colors = 1
|
|
326
|
+
self.lines = 1
|
|
327
|
+
self.buffer = [""]
|
|
328
|
+
self.letterspace = [" "]
|
|
329
|
+
self.chars = {}
|
|
330
|
+
|
|
331
|
+
def add_letter_spacing(self, output, letter_spacing):
|
|
332
|
+
lines = len(output) - self.lines
|
|
333
|
+
for i in range(lines, len(output)):
|
|
334
|
+
idx = i - lines
|
|
335
|
+
space = self.letterspace[idx] if idx < len(self.letterspace) else " "
|
|
336
|
+
output[i] += space * letter_spacing
|
|
337
|
+
return output
|
|
338
|
+
|
|
339
|
+
def add_char(self, output, char):
|
|
340
|
+
lines = len(output) - self.lines
|
|
341
|
+
char_data = self.chars.get(char, [" " * len(self.buffer[0])] * self.lines)
|
|
342
|
+
for i in range(lines, len(output)):
|
|
343
|
+
idx = i - lines
|
|
344
|
+
if idx < len(char_data):
|
|
345
|
+
output[i] += char_data[idx]
|
|
346
|
+
else:
|
|
347
|
+
output[i] += " " * len(self.buffer[0])
|
|
348
|
+
return output
|
|
349
|
+
|
|
350
|
+
def add_line(self, output, buffer, line_height):
|
|
351
|
+
if not output:
|
|
352
|
+
line_height = 0
|
|
353
|
+
for _ in range(line_height):
|
|
354
|
+
output.append("")
|
|
355
|
+
output.extend(buffer)
|
|
356
|
+
return output
|
|
357
|
+
|
|
358
|
+
def clean_input(self, text):
|
|
359
|
+
return "".join(c for c in text if c.upper() in self.CHARS)
|
|
360
|
+
|
|
361
|
+
def char_length(self, character, letter_spacing=0):
|
|
362
|
+
if not character:
|
|
363
|
+
return 1
|
|
364
|
+
char_width = max(len(re.sub(r"(<([^>]+)>)", "", char)) for char in character)
|
|
365
|
+
return char_width if char_width > 0 or letter_spacing == 0 else 1
|
|
366
|
+
|
|
367
|
+
def align_text(self, output, line_length, character_lines, align, size=(80, 24)):
|
|
368
|
+
space = 0
|
|
369
|
+
if align == "center":
|
|
370
|
+
space = (size[0] - line_length) // 2
|
|
371
|
+
elif align == "right":
|
|
372
|
+
space = size[0] - line_length
|
|
373
|
+
if space > 0:
|
|
374
|
+
lines = len(output) - character_lines
|
|
375
|
+
for i in range(lines, len(output)):
|
|
376
|
+
output[i] = " " * space + output[i]
|
|
377
|
+
return output
|
|
378
|
+
|
|
379
|
+
def colorize(self, line, font_colors, colors):
|
|
380
|
+
if font_colors > 1:
|
|
381
|
+
for i in range(font_colors):
|
|
382
|
+
color = colors[i] if i < len(colors) else "system"
|
|
383
|
+
style = self.ansi_style(color, False)
|
|
384
|
+
line = line.replace(f"<c{i+1}>", style.open)
|
|
385
|
+
line = line.replace(f"</c{i+1}>", style.close)
|
|
386
|
+
elif font_colors == 1:
|
|
387
|
+
color = colors[0] if colors else "system"
|
|
388
|
+
style = self.ansi_style(color, False)
|
|
389
|
+
line = style.open + re.sub(r"</?c\d+>", "", line) + style.close
|
|
390
|
+
return line
|
|
391
|
+
|
|
392
|
+
def render_console(self, text, size=(80, 24), colors=None, align="left", letter_spacing=None, line_height=1):
|
|
393
|
+
colors = colors or []
|
|
394
|
+
output = []
|
|
395
|
+
letter_spacing = max((letter_spacing or 1) - 1, 0)
|
|
396
|
+
line_height = max(line_height - 1, 0)
|
|
397
|
+
space = " " * letter_spacing
|
|
398
|
+
output_lines = [space.join(list(line)) for line in re.split(r"\r\n|\r|\n|\|", text.strip())]
|
|
399
|
+
|
|
400
|
+
i = 0
|
|
401
|
+
while i < len(output_lines):
|
|
402
|
+
line = output_lines[i]
|
|
403
|
+
if len(line) > size[0]:
|
|
404
|
+
output_lines[i:i+1] = [line[:size[0]].strip(), line[size[0]:].strip()]
|
|
405
|
+
line = output_lines[i]
|
|
406
|
+
output.append(line)
|
|
407
|
+
output = self.align_text(output, len(line), 1, align, size)
|
|
408
|
+
output = self.add_line(output, [], line_height)
|
|
409
|
+
i += 1
|
|
410
|
+
return output
|
|
411
|
+
|
|
412
|
+
def paint_gradient(self, output, gradient, independent_gradient, lines, font_lines, line_height, transition):
|
|
413
|
+
if independent_gradient:
|
|
414
|
+
buffer = []
|
|
415
|
+
start = 0
|
|
416
|
+
for _ in range(lines):
|
|
417
|
+
temp = output[start:start + font_lines]
|
|
418
|
+
self.add_line(buffer, self.paint_gradient(temp, gradient, False, 1, font_lines, 0, transition), line_height)
|
|
419
|
+
start += font_lines + line_height
|
|
420
|
+
return buffer
|
|
421
|
+
|
|
422
|
+
output = [re.sub(r"</?c\d+>", "", line) for line in output]
|
|
423
|
+
|
|
424
|
+
min_index = float('inf')
|
|
425
|
+
max_index = float('-inf')
|
|
426
|
+
for line in output:
|
|
427
|
+
if line.strip():
|
|
428
|
+
for i, c in enumerate(line):
|
|
429
|
+
if c.strip():
|
|
430
|
+
min_index = min(min_index, i)
|
|
431
|
+
max_index = max(max_index, i)
|
|
432
|
+
|
|
433
|
+
if min_index == float('inf') or max_index == float('-inf'):
|
|
434
|
+
return output
|
|
435
|
+
|
|
436
|
+
styles = self.get_gradient(gradient or [], max_index - min_index + 1, transition)
|
|
437
|
+
new_output = []
|
|
438
|
+
|
|
439
|
+
for line in output:
|
|
440
|
+
if not line.strip():
|
|
441
|
+
new_output.append(line)
|
|
442
|
+
continue
|
|
443
|
+
temp = list(line)
|
|
444
|
+
for i, style in zip(range(min_index, max_index + 1), styles):
|
|
445
|
+
if i >= len(temp) or not temp[i].strip():
|
|
446
|
+
continue
|
|
447
|
+
temp[i] = style.open + temp[i] + style.close
|
|
448
|
+
new_output.append("".join(temp))
|
|
449
|
+
return new_output
|
|
450
|
+
|
|
451
|
+
def render(self, text, font="block", size=(80, 24), colors=None, background="transparent",
|
|
452
|
+
align="left", letter_spacing=None, line_height=1, space=True, max_length=0,
|
|
453
|
+
gradient=None, independent_gradient=False, transition=False, raw=False):
|
|
454
|
+
|
|
455
|
+
colors = colors or []
|
|
456
|
+
font_face = self.Font(self, font)
|
|
457
|
+
|
|
458
|
+
if font == "console":
|
|
459
|
+
output = self.render_console(text, size=size, colors=colors, align=align,
|
|
460
|
+
letter_spacing=letter_spacing, line_height=line_height)
|
|
461
|
+
lines = len(output)
|
|
462
|
+
else:
|
|
463
|
+
lines = 0
|
|
464
|
+
if letter_spacing is None:
|
|
465
|
+
letter_spacing = self.char_length(font_face.letterspace)
|
|
466
|
+
line_length = self.char_length(font_face.buffer)
|
|
467
|
+
output = self.add_line([], font_face.buffer, line_height)
|
|
468
|
+
lines += 1
|
|
469
|
+
output = font_face.add_letter_spacing(output, letter_spacing)
|
|
470
|
+
line_length += self.char_length(font_face.letterspace, letter_spacing) * letter_spacing
|
|
471
|
+
text = self.clean_input(text)
|
|
472
|
+
|
|
473
|
+
for c in text:
|
|
474
|
+
c = c.upper()
|
|
475
|
+
last_line_length = line_length
|
|
476
|
+
|
|
477
|
+
if c != "|":
|
|
478
|
+
line_length += self.char_length(font_face.chars.get(c, [" "]), letter_spacing)
|
|
479
|
+
line_length += self.char_length(font_face.letterspace, letter_spacing) * letter_spacing
|
|
480
|
+
|
|
481
|
+
if c == "|" or line_length > size[0]:
|
|
482
|
+
lines += 1
|
|
483
|
+
output = self.align_text(output, last_line_length, font_face.lines, align, size)
|
|
484
|
+
|
|
485
|
+
line_length = self.char_length(font_face.buffer)
|
|
486
|
+
line_length += self.char_length(font_face.letterspace, letter_spacing) * letter_spacing
|
|
487
|
+
if c != "|":
|
|
488
|
+
line_length += self.char_length(font_face.chars.get(c, [" "]), letter_spacing)
|
|
489
|
+
line_length += self.char_length(font_face.letterspace, letter_spacing) * letter_spacing
|
|
490
|
+
output = self.add_line(output, font_face.buffer, line_height)
|
|
491
|
+
output = font_face.add_letter_spacing(output, letter_spacing)
|
|
492
|
+
|
|
493
|
+
if c != "|":
|
|
494
|
+
output = font_face.add_char(output, c)
|
|
495
|
+
output = font_face.add_letter_spacing(output, letter_spacing)
|
|
496
|
+
|
|
497
|
+
output = self.align_text(output, line_length, font_face.lines, align, size)
|
|
498
|
+
if gradient:
|
|
499
|
+
output = self.paint_gradient(output, gradient, independent_gradient, lines,
|
|
500
|
+
font_face.lines, line_height, transition)
|
|
501
|
+
|
|
502
|
+
output = [self.colorize(line, font_face.colors, colors) for line in output]
|
|
503
|
+
|
|
504
|
+
if space:
|
|
505
|
+
output = [""] * 2 + output + [""] * 2
|
|
506
|
+
|
|
507
|
+
if background != "transparent":
|
|
508
|
+
output = [(line + " " * (size[0] - len(re.sub(r"\x1b\[\d+?m", "", line)))) for line in output]
|
|
509
|
+
style = self.ansi_style(background, True)
|
|
510
|
+
if output:
|
|
511
|
+
output[0] = style.open + output[0]
|
|
512
|
+
output[-1] += style.close
|
|
513
|
+
|
|
514
|
+
if raw:
|
|
515
|
+
return repr("\n".join(output))[1:-1]
|
|
516
|
+
else:
|
|
517
|
+
return "\n".join(output)
|
|
518
|
+
|
|
519
|
+
def say(self, text, **options):
|
|
520
|
+
print(self.render(text, **options))
|
|
521
|
+
|
|
522
|
+
pc = ParasCode()
|
|
523
|
+
|
|
524
|
+
cprint = pc.cprint
|
|
525
|
+
random_string = pc.random_string
|
|
526
|
+
random_number = pc.random_number
|
|
527
|
+
random_user_agent = pc.random_user_agent
|
|
528
|
+
get_client = pc.get_client
|
|
529
|
+
clear = pc.clear
|
|
530
|
+
banner = pc.banner
|
|
531
|
+
colored = pc.colored
|
|
532
|
+
print_colored = pc.print_colored
|
|
533
|
+
clear_screen = pc.clear_screen
|
|
534
|
+
show_fonts = pc.show_fonts
|
|
535
|
+
show_colors = pc.show_colors
|
|
536
|
+
render = pc.render
|
|
537
|
+
say = pc.say
|
|
538
|
+
run = pc.run
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "parascode"
|
|
7
|
-
version = "2.3.
|
|
7
|
+
version = "2.3.3"
|
|
8
8
|
description = "Complete Python Utility Toolkit with cFonts, Social Media OSINT, and more"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{ name = "Paras Chourasiya" }]
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
"""
|
|
3
|
-
ParasCode - Complete Python Utility Toolkit
|
|
4
|
-
Author: Paras Chourasiya
|
|
5
|
-
GitHub: https://github.com/Aptpy
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
from .__version__ import __version__
|
|
9
|
-
from .parascode import (
|
|
10
|
-
ParasCode, pc, cprint, random_string, random_number,
|
|
11
|
-
random_user_agent, get_client, link, expire, clear,
|
|
12
|
-
banner, clear_screen, print_colored, colored,
|
|
13
|
-
render, say, show_fonts, show_colors, show_backgrounds,
|
|
14
|
-
Instagram, Twitter, Tiktok, Facebook, Spotify,
|
|
15
|
-
Email, UserAgent, Curl, Proxy,
|
|
16
|
-
get_country_info, GetMid, coockie, r
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
__all__ = [
|
|
20
|
-
"__version__", "ParasCode", "pc", "cprint", "random_string",
|
|
21
|
-
"random_number", "random_user_agent", "get_client", "link",
|
|
22
|
-
"expire", "clear", "banner", "clear_screen", "print_colored",
|
|
23
|
-
"colored", "render", "say", "show_fonts", "show_colors",
|
|
24
|
-
"show_backgrounds", "Instagram", "Twitter", "Tiktok", "Facebook",
|
|
25
|
-
"Spotify", "Email", "UserAgent", "Curl", "Proxy",
|
|
26
|
-
"get_country_info", "GetMid", "coockie", "r"
|
|
27
|
-
]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.3.1"
|