printcolored 2.1.1__tar.gz → 2.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: printcolored
3
- Version: 2.1.1
3
+ Version: 2.2
4
4
  Requires-Dist: platformdirs
5
5
  Provides-Extra: windows-legacy
6
6
  Requires-Dist: colorama; extra == "windows-legacy"
@@ -0,0 +1,32 @@
1
+
2
+
3
+ from random import *
4
+
5
+ fonts: dict[str, tuple[str, ...]] = {
6
+ "original": ("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","0","1","2","3","4","5","6","7","8","9","!","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_","`","{","|","}","~"),
7
+
8
+ # act like theres stuff here
9
+
10
+
11
+ }
12
+
13
+ random_decorators: dict[str, tuple[str, str]] = {
14
+ "chess": (""),
15
+ }
16
+
17
+ decorators: dict[str, tuple[str, str]] = {
18
+ "barrier": (""),
19
+
20
+ }
21
+
22
+
23
+
24
+ def Fonter(text: str, font: str, decorator: str = "") -> str:
25
+ original = fonts["original"]
26
+ fontedtext = []
27
+ for letter in text:
28
+ fontedtext.append(fonts[font][original.index(letter)] if letter in original else letter)
29
+ result = "".join(fontedtext)
30
+ if decorator == "":
31
+ return result
32
+ return f"{decorators[decorator][0]}{result}{decorators[decorator][1]}"
@@ -29,39 +29,39 @@ from pathlib import Path
29
29
  import json
30
30
  from platformdirs import user_config_dir
31
31
 
32
- CONFIG_DIR = Path(user_config_dir("printColored"))
33
- CUSTOM_FORMATS_PATH = CONFIG_DIR / "custom.json"
32
+ CONFIG_DIR: Path = Path(user_config_dir("printColored"))
33
+ CUSTOM_FORMATS_PATH: Path = CONFIG_DIR / "custom.json"
34
34
 
35
35
 
36
- def load_custom_formats():
36
+ def load_custom_formats() -> dict[str, str]:
37
37
  if CUSTOM_FORMATS_PATH.exists():
38
38
  with open(CUSTOM_FORMATS_PATH, "r") as file:
39
39
  return json.load(file)
40
40
  return {}
41
41
 
42
42
 
43
- def save_custom_formats(formats):
43
+ def save_custom_formats(formats: dict[str, str]) -> None:
44
44
  CONFIG_DIR.mkdir(parents=True, exist_ok=True)
45
45
  with open(CUSTOM_FORMATS_PATH, "w") as file:
46
46
  json.dump(formats, file, indent=4)
47
47
 
48
48
 
49
- def add_custom_format(name, value):
50
- formats = load_custom_formats()
51
- formats[name] = value
52
- save_custom_formats(formats)
53
- return formats
49
+ def add_custom_format(name: str, value: str) -> dict[str, str]:
50
+ global custom_formats
51
+ custom_formats[name] = value
52
+ save_custom_formats(custom_formats)
53
+ return custom_formats
54
54
 
55
55
 
56
- custom_formats = load_custom_formats()
56
+ custom_formats: dict[str, str] = load_custom_formats()
57
57
 
58
58
 
59
59
  from . import Fonter
60
60
  from .formats import ansi_formats, html_colors
61
61
 
62
- _default_source_order = ("ansi_format","rgb_format","custom_format")
62
+ _default_source_order: tuple[str, ...] = ("ansi_format","rgb_format","custom_format")
63
63
 
64
- def _font_check(text, *inputs):
64
+ def _font_check(text: str, *inputs: str) -> str:
65
65
  changed = False
66
66
  font = ""
67
67
  decorator = ""
@@ -74,13 +74,13 @@ def _font_check(text, *inputs):
74
74
  changed = True
75
75
  return Fonter.Fonter(text, font, decorator) if changed == True else text
76
76
 
77
- def _reset(reset):
77
+ def _reset(reset: bool) -> str:
78
78
  if reset:
79
79
  return "\033[0m"
80
80
  else:
81
81
  return ""
82
82
 
83
- def _single_code(fformat, *, html_view="", source_order=()):
83
+ def _single_code(fformat: str, *, html_view: str = "", source_order: tuple[str, ...] = ()) -> str:
84
84
  if fformat.replace(";", "").isdigit():
85
85
  return fformat
86
86
  for source in source_order:
@@ -97,8 +97,8 @@ def _single_code(fformat, *, html_view="", source_order=()):
97
97
  raise ValueError(f"{source}: Unknown Format Source!")
98
98
  raise ValueError(f"{fformat}: Unknown Format!")
99
99
 
100
- def _build_code(*formats_used, html_view="", source_order=()):
101
- code_list = []
100
+ def _build_code(*formats_used: str, html_view: str = "", source_order: tuple[str, ...] = ()) -> str:
101
+ code_list: list[str] = []
102
102
  for name in formats_used:
103
103
  name = _single_code(name, html_view=html_view, source_order=source_order)
104
104
  if name != None:
@@ -106,7 +106,7 @@ def _build_code(*formats_used, html_view="", source_order=()):
106
106
 
107
107
  return ";".join(code_list)
108
108
 
109
- def _rgb_validation(r,g,b):
109
+ def _rgb_validation(r: str, g: str, b: str) -> str:
110
110
  if r == "" and g == "" and b == "":
111
111
  return ""
112
112
  elif r == "" or g == "" or b == "":
@@ -119,42 +119,42 @@ def _rgb_validation(r,g,b):
119
119
 
120
120
 
121
121
  class Theme:
122
- def __init__(self, *formats_used):
123
- self.formats_used = formats_used
122
+ def __init__(self, *formats_used: str) -> None:
123
+ self.formats_used: tuple[str, ...] = formats_used
124
124
 
125
- def print(self, text, *, reset=True, html_view="", source_order=_default_source_order):
125
+ def print(self, text: str, *, reset: bool = True, html_view: str = "", source_order: tuple[str, ...] = _default_source_order) -> None:
126
126
  text = _font_check(text, *self.formats_used)
127
- self.format_code = _build_code(*self.formats_used, html_view=html_view, source_order=source_order)
128
- reset = _reset(reset)
129
- print(f"\033[{self.format_code}m{text}{reset}")
127
+ self.format_code: str = _build_code(*self.formats_used, html_view=html_view, source_order=source_order)
128
+ reset_code = _reset(reset)
129
+ print(f"\033[{self.format_code}m{text}{reset_code}")
130
130
 
131
- def overwrite(self, *new):
131
+ def overwrite(self, *new: str) -> None:
132
132
  self.formats_used = new
133
133
 
134
- def add(self, *new):
134
+ def add(self, *new: str) -> None:
135
135
  self.formats_used = self.formats_used + new
136
136
 
137
- def remove(self, *removed):
137
+ def remove(self, *removed: str) -> None:
138
138
  self.formats_used = tuple(fformat for fformat in self.formats_used if fformat not in removed)
139
139
 
140
- def showUsed(self):
140
+ def showUsed(self) -> None:
141
141
  print(self.formats_used)
142
142
 
143
- def __str__(self):
143
+ def __str__(self) -> str:
144
144
  return str(self.formats_used)
145
145
 
146
146
 
147
147
  class ThemeRGBV(Theme):
148
- def __init__(self, r="", g="", b="", r2="", g2="", b2="", *formats_used):
148
+ def __init__(self, r: str = "", g: str = "", b: str = "", r2: str = "", g2: str = "", b2: str = "", *formats_used: str) -> None:
149
149
  super().__init__(*formats_used)
150
150
 
151
- self.fg = _rgb_validation(r,g,b)
152
- self.bg = _rgb_validation(r2,g2,b2)
151
+ self.fg: str = _rgb_validation(r,g,b)
152
+ self.bg: str = _rgb_validation(r2,g2,b2)
153
153
 
154
- def print(self, text, *, reset=True, html_view="", source_order=_default_source_order):
154
+ def print(self, text: str, *, reset: bool = True, html_view: str = "", source_order: tuple[str, ...] = _default_source_order) -> None:
155
155
  text = _font_check(text, *self.formats_used)
156
156
  self.format_code = _build_code(*self.formats_used, html_view=html_view, source_order=source_order)
157
- reset = _reset(reset)
157
+ reset_code = _reset(reset)
158
158
 
159
159
  if self.format_code:
160
160
  self.format_code += ";"
@@ -163,43 +163,43 @@ class ThemeRGBV(Theme):
163
163
  if self.bg == "":
164
164
  super().print(text, reset=reset, html_view=html_view, source_order=source_order)
165
165
  else:
166
- self.rgbcode = "48;2;" + self.bg
167
- self.finalcode = self.format_code + self.rgbcode
168
- print(f"\033[{self.finalcode}m{text}{reset}")
166
+ self.rgbcode: str = "48;2;" + self.bg
167
+ self.finalcode: str = self.format_code + self.rgbcode
168
+ print(f"\033[{self.finalcode}m{text}{reset_code}")
169
169
  else:
170
170
  if self.bg == "":
171
171
  self.rgbcode = "38;2;" + self.fg
172
172
  self.finalcode = self.format_code + self.rgbcode
173
- print(f"\033[{self.finalcode}m{text}{reset}")
173
+ print(f"\033[{self.finalcode}m{text}{reset_code}")
174
174
  else:
175
175
  self.rgbcode = "38;2;" + self.fg + ";48;2;" + self.bg
176
176
  self.finalcode = self.format_code + self.rgbcode
177
- print(f"\033[{self.finalcode}m{text}{reset}")
177
+ print(f"\033[{self.finalcode}m{text}{reset_code}")
178
178
 
179
- def overwrite(self, r,g,b, r2,g2,b2, *new):
179
+ def overwrite(self, r: str, g: str, b: str, r2: str, g2: str, b2: str, *new: str) -> None:
180
180
  super().overwrite(*new)
181
181
 
182
182
  self.fg = _rgb_validation(r,g,b)
183
183
  self.bg = _rgb_validation(r2,g2,b2)
184
184
 
185
- def showUsed(self):
185
+ def showUsed(self) -> None:
186
186
  print(f"Foreground: {self.fg}")
187
187
  print(f"Background: {self.bg}")
188
188
  print(f"Formats: {self.formats_used}")
189
189
 
190
- def __str__(self):
191
- return self.fg +";"+ self.bg +" "+ self.formats_used
190
+ def __str__(self) -> str:
191
+ return self.fg +";"+ self.bg +" "+ str(self.formats_used)
192
192
 
193
193
 
194
- def printColored(text, *formats_used, reset= True, html_view="", source_order=_default_source_order):
194
+ def printColored(text: str, *formats_used: str, reset: bool = True, html_view: str = "", source_order: tuple[str, ...] = _default_source_order) -> None:
195
195
  text = _font_check(text, *formats_used)
196
196
  code = _build_code(*formats_used, html_view=html_view, source_order=source_order)
197
- reset = _reset(reset)
197
+ reset_code = _reset(reset)
198
198
 
199
- print(f"\033[{code}m{text}{reset}")
199
+ print(f"\033[{code}m{text}{reset_code}")
200
200
 
201
201
 
202
- def colorGen(*formats_used, mode="", html_view="", source_order=_default_source_order):
202
+ def colorGen(*formats_used: str, mode: str = "", html_view: str = "", source_order: tuple[str, ...] = _default_source_order) -> str:
203
203
  code = _build_code(*formats_used, html_view=html_view, source_order=source_order)
204
204
  if mode == "b":
205
205
  return code
@@ -212,10 +212,10 @@ def colorGen(*formats_used, mode="", html_view="", source_order=_default_source_
212
212
  # now colorGen is also fixed
213
213
 
214
214
 
215
- def printl(text=(), formats_used=(), *, sepr=""):
215
+ def printl(text: tuple[str, ...] = (), formats_used: tuple[str | tuple[str, ...], ...] = (), *, sepr: str = "") -> None:
216
216
 
217
217
  for i, (line, fformat) in enumerate(zip(text, formats_used)):
218
- code = []
218
+ code: list[str] = []
219
219
  line = _font_check(line, fformat)
220
220
  if type(fformat) == str:
221
221
  fformat = _single_code(fformat)
@@ -236,10 +236,10 @@ def printl(text=(), formats_used=(), *, sepr=""):
236
236
  # Dunno if i should keep colorGen, but ill just leave it there because
237
237
  # it returns the color code itself
238
238
 
239
- def printRGB(text, r,g,b, *formats_used, view="", html_view="",reset=True, source_order=_default_source_order):
239
+ def printRGB(text: str, r: str, g: str, b: str, *formats_used: str, view: str = "", html_view: str = "", reset: bool = True, source_order: tuple[str, ...] = _default_source_order) -> None:
240
240
  text = _font_check(text, *formats_used)
241
241
  code = _build_code(*formats_used, html_view=html_view, source_order=source_order)
242
- reset = _reset(reset)
242
+ reset_code = _reset(reset)
243
243
  # if you dont want a format when using the rgb function,
244
244
  # you can just not enter it
245
245
  rgbvalue = _rgb_validation(r,g,b)
@@ -252,13 +252,13 @@ def printRGB(text, r,g,b, *formats_used, view="", html_view="",reset=True, sourc
252
252
  code = ";" + code
253
253
 
254
254
 
255
- print(f"\033[{viewvalue}2;{rgbvalue}{code}m{text}{reset}")
255
+ print(f"\033[{viewvalue}2;{rgbvalue}{code}m{text}{reset_code}")
256
256
 
257
257
 
258
- def printRGBV(text, r,g,b, r2, g2, b2, *formats_used, reset=True, html_view="", source_order=_default_source_order):
258
+ def printRGBV(text: str, r: str, g: str, b: str, r2: str, g2: str, b2: str, *formats_used: str, reset: bool = True, html_view: str = "", source_order: tuple[str, ...] = _default_source_order) -> None:
259
259
  text = _font_check(text, *formats_used)
260
260
  code = _build_code(*formats_used, html_view=html_view, source_order=source_order)
261
- reset = _reset(reset)
261
+ reset_code = _reset(reset)
262
262
 
263
263
  fg = _rgb_validation(r,g,b)
264
264
  bg = _rgb_validation(r2,g2,b2)
@@ -268,35 +268,35 @@ def printRGBV(text, r,g,b, r2, g2, b2, *formats_used, reset=True, html_view="",
268
268
 
269
269
  if fg == "":
270
270
  if bg == "":
271
- print(f"\033[{code}m{text}{reset}")
271
+ print(f"\033[{code}m{text}{reset_code}")
272
272
  else:
273
- print(f"\033[{code}48;2;{bg}m{text}{reset}")
273
+ print(f"\033[{code}48;2;{bg}m{text}{reset_code}")
274
274
  else:
275
275
  if bg == "":
276
- print(f"\033[{code}38;2;{fg}m{text}{reset}")
276
+ print(f"\033[{code}38;2;{fg}m{text}{reset_code}")
277
277
  else:
278
- print(f"\033[{code}38;2;{fg};48;2;{bg}m{text}{reset}")
278
+ print(f"\033[{code}38;2;{fg};48;2;{bg}m{text}{reset_code}")
279
279
 
280
280
 
281
- def formatfinder(min, max): # made this to find new formats, theres nothing beyond 107
281
+ def formatfinder(val1: str, val2: str) -> None: # made this to find new formats, theres nothing beyond 107
282
282
  # btw use strings ("1","108") and not integers (1,108)
283
- if min.isdigit() and max.isdigit():
284
- min = int(min)
285
- max = int(max)
286
- for code in range(min, max+1):
283
+ if val1.isdigit() and val2.isdigit():
284
+ num1 = int(val1)
285
+ num2 = int(val2)
286
+ for code in range(num1, num2+1):
287
287
  print(f"At iteration {code}: \033[{code}mHello World!\033[0m")
288
- elif min == "font" or max == "font":
288
+ elif val1 == "font" or val2 == "font":
289
289
  for key, value in Fonter.fonts.items():
290
290
  print(f"{key}: {value}")
291
- elif min == "decors" or max == "decors":
291
+ elif val1 == "decors" or val2 == "decors":
292
292
  for key, value in Fonter.decorators.items():
293
293
  print(f"{key}: {value}")
294
- elif min == "ansi_dict" or max == "ansi_dict":
294
+ elif val1 == "ansi_dict" or val2 == "ansi_dict":
295
295
  for key, value in ansi_formats.items():
296
296
  print(f"\033[{value}m{key}\033[0m")
297
- elif min == "html_dict" or max == "html_dict":
297
+ elif val1 == "html_dict" or val2 == "html_dict":
298
298
  for key, value in html_colors.items():
299
299
  print(f"\033[38;2;{value}m{key}\033[0m")
300
- elif min == "custom_dict" or max == "custom_dict":
300
+ elif val1 == "custom_dict" or val2 == "custom_dict":
301
301
  for key, value in custom_formats.items():
302
- print(f"\033[{value}m{key}\033[0m")
302
+ print(f"\033[{value}m{key}\033[0m")
@@ -1,45 +1,46 @@
1
- from .core import formatfinder
2
-
3
- def ansi_range():
4
- print("All possible formats in range of 1-107:")
5
- formatfinder("1","107")
6
-
7
- def all_ansi_dict_formats():
8
- print("All available formats:")
9
- formatfinder("ansi_dict","")
10
-
11
- def all_html_formats():
12
- print("All HTML formats:")
13
- formatfinder("html_dict","")
14
-
15
- def all_custom_formats():
16
- print("All custom formats:")
17
- formatfinder("custom_dict","")
18
-
19
- def all_fonts():
20
- print("All fonts available:")
21
- formatfinder(" ","font")
22
-
23
- def all_decors():
24
- print("All decorators available:")
25
- formatfinder(" ","decors")
26
-
27
- display = {
28
- "all_ansi_formats": ansi_range,
29
- "ansi_dict": all_ansi_dict_formats,
30
- "html_dict": all_html_formats,
31
- "custom_dict": all_custom_formats,
32
- "fonts": all_fonts,
33
- "decorators": all_decors
34
- }
35
-
36
-
37
- def display_formats(selected_source=None):
38
- if selected_source:
39
- if selected_source in display:
40
- display[selected_source]()
41
- else:
42
- raise ValueError(f"{selected_source} Not a valid format source!")
43
- else:
44
- for source in display:
45
- display[source]()
1
+ from collections.abc import Callable
2
+ from .core import formatfinder
3
+
4
+ def ansi_range() -> None:
5
+ print("All possible formats in range of 1-107:")
6
+ formatfinder("1","107")
7
+
8
+ def all_ansi_dict_formats() -> None:
9
+ print("All available formats:")
10
+ formatfinder("ansi_dict","")
11
+
12
+ def all_html_formats() -> None:
13
+ print("All HTML formats:")
14
+ formatfinder("html_dict","")
15
+
16
+ def all_custom_formats() -> None:
17
+ print("All custom formats:")
18
+ formatfinder("custom_dict","")
19
+
20
+ def all_fonts() -> None:
21
+ print("All fonts available:")
22
+ formatfinder(" ","font")
23
+
24
+ def all_decors() -> None:
25
+ print("All decorators available:")
26
+ formatfinder(" ","decors")
27
+
28
+ display: dict[str, Callable[[], None]] = {
29
+ "all_ansi_formats": ansi_range,
30
+ "ansi_dict": all_ansi_dict_formats,
31
+ "html_dict": all_html_formats,
32
+ "custom_dict": all_custom_formats,
33
+ "fonts": all_fonts,
34
+ "decorators": all_decors
35
+ }
36
+
37
+
38
+ def display_formats(selected_source: str | None = None) -> None:
39
+ if selected_source:
40
+ if selected_source in display:
41
+ display[selected_source]()
42
+ else:
43
+ raise ValueError(f"{selected_source} Not a valid format source!")
44
+ else:
45
+ for source in display:
46
+ display[source]()
@@ -1,4 +1,4 @@
1
- ansi_formats = { # i think the dictonary now contains every possible format
1
+ ansi_formats: dict[str, str] = { # i think the dictonary now contains every possible format
2
2
  # Colors
3
3
  "gray" : "30",
4
4
  "red" : "31",
@@ -55,7 +55,7 @@ ansi_formats = { # i think the dictonary now contains every possible format
55
55
  "" : "0"
56
56
  }
57
57
 
58
- html_colors = { # note that just like normal rgb, using two at same time,
58
+ html_colors: dict[str, str] = { # note that just like normal rgb, using two at same time,
59
59
  # the last overwrites all before it.
60
60
  # also note that the format keys are written in a different way
61
61
  # than i write bc it was copypasted from html website
@@ -71,8 +71,6 @@ html_colors = { # note that just like normal rgb, using two at same time,
71
71
  "Pink": "255;192;203",
72
72
  "LightPink": "255;182;193",
73
73
  "HotPink": "255;105;180",
74
- # ^ i am NOT the one in charge of writing these
75
- # ᵇᵘᵗ ⁱ ᵃᶜᵗᵘᵃˡˡʸ ᵗʰⁱⁿᵏ ᵗʰᵃᵗ ᵗʰⁱˢ ᵖⁱⁿᵏ ⁱˢ ᵃᵇⁱᵗ ʰ⁻
76
74
  "DeepPink": "255;20;147",
77
75
  "MediumVioletRed": "199;21;133",
78
76
  "PaleVioletRed": "219;112;147",
@@ -1,133 +1,134 @@
1
- from .core import *
2
-
3
- _deco = Theme("green", "bold")
4
- _deco2 = Theme("bright_blue", "bold")
5
- _deco3 = Theme("bright_yellow")
6
- _border = "--------------------------------"
7
-
8
-
9
- def _guide_printColored():
10
- _deco.print(_border)
11
- print("printColored()")
12
- printColored("Example use of printColored()".center(32), "green", "bold", "italic")
13
- print("Main function, enter text, then formats, and the text will come formatted based on the provided formats")
14
- print("Take a look at the dictionary and enter formats to use")
15
- _deco.print(_border)
16
-
17
-
18
- def _guide_colorGen():
19
- _deco.print(_border)
20
- print("colorGen()")
21
- print(
22
- f"{colorGen('red', 'bold')} Example use "
23
- f"{colorGen('', 'strikethrough', 'blue')}of colorGen()"
24
- f"{colorGen('')}"
25
- )
26
-
27
- genformat1 = colorGen("bright_white", "highlight_blue")
28
- genformat2 = colorGen("", "yellow", "highlight_green", "underline")
29
- print(f" {genformat1}Example 2 {genformat2}of colorGen(){colorGen('')}")
30
- print("This is used to enter many formats in the same line")
31
- _deco.print(_border)
32
-
33
-
34
- def _guide_printl():
35
- _deco.print(_border)
36
- print("printl()")
37
- printl(("Example", "use", "of", "printl()"), ("green", ("36", "italic"), "yellow", "magenta"), sepr=" ")
38
- print("Printl is used to print many text in same line each with their own formats")
39
- _deco.print(_border)
40
-
41
-
42
- def _guide_printRGB():
43
- _deco.print(_border)
44
- print("printRGB()")
45
- printRGB("Example use of printRGB()".center(32), "255", "0", "255", "bold", view="")
46
- printRGB("Example 2 of printRGB()".center(32), "0", "255", "255", view="bg")
47
- print("Notice how it can only display either")
48
- print("foreground or background at one time")
49
- print("You can also add formats to it".center(32))
50
- _deco.print(_border)
51
-
52
-
53
- def _guide_printRGBV():
54
- _deco.print(_border)
55
- print("printRGBV()")
56
- printRGBV("Example use of printRGBV()".center(32), "0", "255", "0", "0", "0", "255", "")
57
- printRGBV("Example 2 of printRGBV()".center(32), "0", "0", "0", "255", "0", "255", "italic")
58
- print("It can display both foreground and background")
59
- print("and also add formats".center(32))
60
- print("Note that sometimes the background")
61
- print("color blocks the foreground color")
62
- _deco.print(_border)
63
-
64
-
65
- def _guide_theme():
66
- _deco.print(_border)
67
- print("Theme")
68
- deadly = Theme("brightred", "double_underline", "bold")
69
- deadly.print("Example use of Theme class")
70
- print("It can be used for formats that you use many times")
71
-
72
- deadly.add("strikethrough")
73
- deadly.print("Example of add(*formats)")
74
-
75
- deadly.remove("double_underline", "strikethrough")
76
- deadly.print("Example of remove(*formats)")
77
-
78
- deadly.overwrite("highlight_brightred", "underline")
79
- deadly.print("Example of overwrite(*formats)")
80
-
81
- deadly.showUsed()
82
- print("showUsed() displays the current formats")
83
- _deco.print(_border)
84
-
85
-
86
- def _guide_theme_rgbv():
87
- _deco.print(_border)
88
- print("ThemeRGBV")
89
- classified = ThemeRGBV("255", "255", "255", "0", "0", "0", "")
90
- classified.print("Example of printRGBV(r,g,b,r2,g2,b2,*formats)")
91
- print("It can change both foreground and background")
92
- print("and you can choose to use one or both")
93
-
94
- classified.add("bold", "underline")
95
- classified.print("Example of add(*formats)")
96
-
97
- classified.remove("underline")
98
- classified.print("Example of remove(*formats)")
99
- print("Adding/removing only affects formats")
100
-
101
- classified.overwrite("0", "0", "0", "255", "255", "255", "strikethrough")
102
- classified.print("Example of overwrite(r,g,b,r2,g2,b2,*new)")
103
- print("Overwrite rewrites the whole object")
104
-
105
- classified.showUsed()
106
- print("showUsed() displays the current settings")
107
- _deco.print(_border)
108
-
109
-
110
- GUIDE = {
111
- "printColored": _guide_printColored,
112
- "colorGen": _guide_colorGen,
113
- "printl": _guide_printl,
114
- "printRGB": _guide_printRGB,
115
- "printRGBV": _guide_printRGBV,
116
- "Theme": _guide_theme,
117
- "ThemeRGBV": _guide_theme_rgbv,
118
- }
119
-
120
-
121
- def func_guide(selected_function=None):
122
- if selected_function:
123
- if selected_function in GUIDE:
124
- GUIDE[selected_function]()
125
- else:
126
- raise ValueError(f"{selected_function} Not a valid guide section!")
127
- else:
128
- for section in GUIDE:
129
- GUIDE[section]()
130
- _deco.print(_border)
131
- _deco2.print(_border)
132
- print("Thanks for reading!")
1
+ from collections.abc import Callable
2
+ from .core import *
3
+
4
+ _deco: Theme = Theme("green", "bold")
5
+ _deco2: Theme = Theme("bright_blue", "bold")
6
+ _deco3: Theme = Theme("bright_yellow")
7
+ _border: str = "--------------------------------"
8
+
9
+
10
+ def _guide_printColored() -> None:
11
+ _deco.print(_border)
12
+ print("printColored()")
13
+ printColored("Example use of printColored()".center(32), "green", "bold", "italic")
14
+ print("Main function, enter text, then formats, and the text will come formatted based on the provided formats")
15
+ print("Take a look at the dictionary and enter formats to use")
16
+ _deco.print(_border)
17
+
18
+
19
+ def _guide_colorGen() -> None:
20
+ _deco.print(_border)
21
+ print("colorGen()")
22
+ print(
23
+ f"{colorGen('red', 'bold')} Example use "
24
+ f"{colorGen('', 'strikethrough', 'blue')}of colorGen()"
25
+ f"{colorGen('')}"
26
+ )
27
+
28
+ genformat1 = colorGen("bright_white", "highlight_blue")
29
+ genformat2 = colorGen("", "yellow", "highlight_green", "underline")
30
+ print(f" {genformat1}Example 2 {genformat2}of colorGen(){colorGen('')}")
31
+ print("This is used to enter many formats in the same line")
32
+ _deco.print(_border)
33
+
34
+
35
+ def _guide_printl() -> None:
36
+ _deco.print(_border)
37
+ print("printl()")
38
+ printl(("Example", "use", "of", "printl()"), ("green", ("36", "italic"), "yellow", "magenta"), sepr=" ")
39
+ print("Printl is used to print many text in same line each with their own formats")
40
+ _deco.print(_border)
41
+
42
+
43
+ def _guide_printRGB() -> None:
44
+ _deco.print(_border)
45
+ print("printRGB()")
46
+ printRGB("Example use of printRGB()".center(32), "255", "0", "255", "bold", view="")
47
+ printRGB("Example 2 of printRGB()".center(32), "0", "255", "255", view="bg")
48
+ print("Notice how it can only display either")
49
+ print("foreground or background at one time")
50
+ print("You can also add formats to it".center(32))
51
+ _deco.print(_border)
52
+
53
+
54
+ def _guide_printRGBV() -> None:
55
+ _deco.print(_border)
56
+ print("printRGBV()")
57
+ printRGBV("Example use of printRGBV()".center(32), "0", "255", "0", "0", "0", "255", "")
58
+ printRGBV("Example 2 of printRGBV()".center(32), "0", "0", "0", "255", "0", "255", "italic")
59
+ print("It can display both foreground and background")
60
+ print("and also add formats".center(32))
61
+ print("Note that sometimes the background")
62
+ print("color blocks the foreground color")
63
+ _deco.print(_border)
64
+
65
+
66
+ def _guide_theme() -> None:
67
+ _deco.print(_border)
68
+ print("Theme")
69
+ deadly = Theme("brightred", "double_underline", "bold")
70
+ deadly.print("Example use of Theme class")
71
+ print("It can be used for formats that you use many times")
72
+
73
+ deadly.add("strikethrough")
74
+ deadly.print("Example of add(*formats)")
75
+
76
+ deadly.remove("double_underline", "strikethrough")
77
+ deadly.print("Example of remove(*formats)")
78
+
79
+ deadly.overwrite("highlight_brightred", "underline")
80
+ deadly.print("Example of overwrite(*formats)")
81
+
82
+ deadly.showUsed()
83
+ print("showUsed() displays the current formats")
84
+ _deco.print(_border)
85
+
86
+
87
+ def _guide_theme_rgbv() -> None:
88
+ _deco.print(_border)
89
+ print("ThemeRGBV")
90
+ classified = ThemeRGBV("255", "255", "255", "0", "0", "0", "")
91
+ classified.print("Example of printRGBV(r,g,b,r2,g2,b2,*formats)")
92
+ print("It can change both foreground and background")
93
+ print("and you can choose to use one or both")
94
+
95
+ classified.add("bold", "underline")
96
+ classified.print("Example of add(*formats)")
97
+
98
+ classified.remove("underline")
99
+ classified.print("Example of remove(*formats)")
100
+ print("Adding/removing only affects formats")
101
+
102
+ classified.overwrite("0", "0", "0", "255", "255", "255", "strikethrough")
103
+ classified.print("Example of overwrite(r,g,b,r2,g2,b2,*new)")
104
+ print("Overwrite rewrites the whole object")
105
+
106
+ classified.showUsed()
107
+ print("showUsed() displays the current settings")
108
+ _deco.print(_border)
109
+
110
+
111
+ GUIDE: dict[str, Callable[[], None]] = {
112
+ "printColored": _guide_printColored,
113
+ "colorGen": _guide_colorGen,
114
+ "printl": _guide_printl,
115
+ "printRGB": _guide_printRGB,
116
+ "printRGBV": _guide_printRGBV,
117
+ "Theme": _guide_theme,
118
+ "ThemeRGBV": _guide_theme_rgbv,
119
+ }
120
+
121
+
122
+ def func_guide(selected_function: str | None = None) -> None:
123
+ if selected_function:
124
+ if selected_function in GUIDE:
125
+ GUIDE[selected_function]()
126
+ else:
127
+ raise ValueError(f"{selected_function} Not a valid guide section!")
128
+ else:
129
+ for section in GUIDE:
130
+ GUIDE[section]()
131
+ _deco.print(_border)
132
+ _deco2.print(_border)
133
+ print("Thanks for reading!")
133
134
  _deco2.print(_border)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: printcolored
3
- Version: 2.1.1
3
+ Version: 2.2
4
4
  Requires-Dist: platformdirs
5
5
  Provides-Extra: windows-legacy
6
6
  Requires-Dist: colorama; extra == "windows-legacy"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "printcolored"
3
- version = "2.1.1"
3
+ version = "2.2"
4
4
  dependencies = ["platformdirs"]
5
5
 
6
6
  [project.optional-dependencies]
@@ -1,84 +0,0 @@
1
- """
2
- credits to https://lingojam.com/FancyTextGenerator for all fonts
3
- """
4
- #also note that sometimes some characters are displayed on the same
5
- #place for example the W&O and H&E in the san_andreas font
6
-
7
-
8
- from random import *
9
-
10
- fonts = {
11
- "original": ("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","0","1","2","3","4","5","6","7","8","9","!","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_","`","{","|","}","~"),
12
-
13
- "san_andreas":("𝔞","𝔟","𝔠","𝔡","𝔢","𝔣","𝔤","𝔥","𝔦","𝔧","𝔨","𝔩","𝔪","𝔫","𝔬","𝔭","𝔮","𝔯","𝔰","𝔱","𝔲","𝔳","𝔴","𝔵","𝔶","𝔷","𝔄","𝔅","ℭ","𝔇","𝔈","𝔉","𝔊","ℌ","ℑ","𝔍","𝔎","𝔏","𝔐","𝔑","𝔒","𝔓","𝔔","ℜ","𝔖","𝔗","𝔘","𝔙","𝔚","𝔛","𝔜","ℨ"," ","0","1","2","3","4","5","6","7","8","9","!","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_","`","{","|","}","~"),
14
-
15
- "san_andreas_bold":("𝖆","𝖇","𝖈","𝖉","𝖊","𝖋","𝖌","𝖍","𝖎","𝖏","𝖐","𝖑","𝖒","𝖓","𝖔","𝖕","𝖖","𝖗","𝖘","𝖙","𝖚","𝖛","𝖜","𝖝","𝖞","𝖟","𝕬","𝕭","𝕮","𝕯","𝕰","𝕱","𝕲","𝕳","𝕴","𝕵","𝕶","𝕷","𝕸","𝕹","𝕺","𝕻","𝕼","𝕽","𝕾","𝕿","𝖀","𝖁","𝖂","𝖃","𝖄","𝖅"," ","0","1","2","3","4","5","6","7","8","9","!","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_","`","{","|","}","~"),
16
-
17
- "fancy_bold": ("𝓪","𝓫","𝓬","𝓭","𝓮","𝓯","𝓰","𝓱","𝓲","𝓳","𝓴","𝓵","𝓶","𝓷","𝓸","𝓹","𝓺","𝓻","𝓼","𝓽","𝓾","𝓿","𝔀","𝔁","𝔂","𝔃","𝓐","𝓑","𝓒","𝓓","𝓔","𝓕","𝓖","𝓗","𝓘","𝓙","𝓚","𝓛","𝓜","𝓝","𝓞","𝓟","𝓠","𝓡","𝓢","𝓣","𝓤","𝓥","𝓦","𝓧","𝓨","𝓩"," ","0","1","2","3","4","5","6","7","8","9","!","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_","`","{","|","}","~"),
18
-
19
- "fancy":("𝒶","𝒷","𝒸","𝒹","𝑒","𝒻","𝑔","𝒽","𝒾","𝒿","𝓀","𝓁","𝓂","𝓃","𝑜","𝓅","𝓆","𝓇","𝓈","𝓉","𝓊","𝓋","𝓌","𝓍","𝓎","𝓏","𝒜","𝐵","𝒞","𝒟","𝐸","𝐹","𝒢","𝐻","𝐼","𝒥","𝒦","𝐿","𝑀","𝒩","𝒪","𝒫","𝒬","𝑅","𝒮","𝒯","𝒰","𝒱","𝒲","𝒳","𝒴","𝒵"," ","𝟢","𝟣","𝟤","𝟥","𝟦","𝟧","𝟨","𝟩","𝟪","𝟫","!","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_","`","{","|","}","~"),
20
-
21
- "hollow": ("𝕒","𝕓","𝕔","𝕕","𝕖","𝕗","𝕘","𝕙","𝕚","𝕛","𝕜","𝕝","𝕞","𝕟","𝕠","𝕡","𝕢","𝕣","𝕤","𝕥","𝕦","𝕧","𝕨","𝕩","𝕪","𝕫","𝔸","𝔹","ℂ","𝔻","𝔼","𝔽","𝔾","ℍ","𝕀","𝕁","𝕂","𝕃","𝕄","ℕ","𝕆","ℙ","ℚ","ℝ","𝕊","𝕋","𝕌","𝕍","𝕎","𝕏","𝕐","ℤ"," ","𝟘","𝟙","𝟚","𝟛","𝟜","𝟝","𝟞","𝟟","𝟠","𝟡","!","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_","`","{","|","}","~"),
22
-
23
- "large": ("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","0","1","2","3","4","5","6","7","8","9","!","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_","`","{","|","}","~"),
24
-
25
- "small": ("ᴀ","ʙ","ᴄ","ᴅ","ᴇ","ꜰ","ɢ","ʜ","ɪ","ᴊ","ᴋ","ʟ","ᴍ","ɴ","ᴏ","ᴘ","Q","ʀ","ꜱ","ᴛ","ᴜ","ᴠ","ᴡ","x","ʏ","ᴢ","ᴀ","ʙ","ᴄ","ᴅ","ᴇ","ꜰ","ɢ","ʜ","ɪ","ᴊ","ᴋ","ʟ","ᴍ","ɴ","ᴏ","ᴘ","Q","ʀ","ꜱ","ᴛ","ᴜ","ᴠ","ᴡ","x","ʏ","ᴢ"," ","0","1","2","3","4","5","6","7","8","9","!","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_","`","{","|","}","~"),
26
-
27
- "chinese": ("ꍏ","ꌃ","ꉓ","ꀸ","ꍟ","ꎇ","ꁅ","ꃅ","ꀤ","ꀭ","ꀘ","꒒","ꂵ","ꈤ","ꂦ","ꉣ","ꆰ","ꋪ","ꌗ","꓄","ꀎ","ꃴ","ꅏ","ꊼ","ꌩ","ꁴ","ꍏ","ꌃ","ꉓ","ꀸ","ꍟ","ꎇ","ꁅ","ꃅ","ꀤ","ꀭ","ꀘ","꒒","ꂵ","ꈤ","ꂦ","ꉣ","ꆰ","ꋪ","ꌗ","꓄","ꀎ","ꃴ","ꅏ","ꊼ","ꌩ","ꁴ"," ","0","1","2","3","4","5","6","7","8","9","!","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_","`","{","|","}","~"),
28
-
29
- "squared": ("🅰","🅱","🅲","🅳","🅴","🅵","🅶","🅷","🅸","🅹","🅺","🅻","🅼","🅽","🅾","🅿","🆀","🆁","🆂","🆃","🆄","🆅","🆆","🆇","🆈","🆉","🅰","🅱","🅲","🅳","🅴","🅵","🅶","🅷","🅸","🅹","🅺","🅻","🅼","🅽","🅾","🅿","🆀","🆁","🆂","🆃","🆄","🆅","🆆","🆇","🆈","🆉"," ","0","1","2","3","4","5","6","7","8","9","!","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_","`","{","|","}","~"),
30
-
31
- "pointed": ("a͎","b͎","c͎","d͎","e͎","f͎","g͎","h͎","i͎","j͎","k͎","l͎","m͎","n͎","o͎","p͎","q͎","r͎","s͎","t͎","u͎","v͎","w͎","x͎","y͎","z͎","A͎","B͎","C͎","D͎","E͎","F͎","G͎","H͎","I͎","J͎","K͎","L͎","M͎","N͎","O͎","P͎","Q͎","R͎","S͎","T͎","U͎","V͎","W͎","X͎","Y͎","Z͎"," ͎","0͎","1͎","2͎","3͎","4͎","5͎","6͎","7͎","8͎","9͎","!͎","$͎","%͎","&͎",",","(͎",")͎","*͎","+͎",",","-͎",".͎","/͎",":͎",";͎","<͎","=͎",">͎","?͎","@͎","[͎","\͎","]͎","^͎","_͎","`͎","{͎","|͎","}͎","~͎"),
32
-
33
- "power": ("ᵃ","ᵇ","ᶜ","ᵈ","ᵉ","ᶠ","ᵍ","ʰ","ⁱ","ʲ","ᵏ","ˡ","ᵐ","ⁿ","ᵒ","ᵖ","q","ʳ","ˢ","ᵗ","ᵘ","ᵛ","ʷ","ˣ","ʸ","ᶻ","ᴬ","ᴮ","ᶜ","ᴰ","ᴱ","ᶠ","ᴳ","ᴴ","ᴵ","ᴶ","ᴷ","ᴸ","ᴹ","ᴺ","ᴼ","ᴾ","Q","ᴿ","ˢ","ᵀ","ᵁ","ⱽ","ᵂ","ˣ","ʸ","ᶻ"," ","⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","!","$","%","&",",","⁽","⁾","*","⁺",",","⁻",".","/",":",";","<","⁼",">","?","@","[","\\","]","^","_","`","{","|","}","~"),
34
-
35
- "weird": ("ᗩ","ᗷ","ᑕ","ᗪ","E","ᖴ","G","ᕼ","I","ᒍ","K","ᒪ","ᗰ","ᑎ","O","ᑭ","ᑫ","ᖇ","ᔕ","T","ᑌ","ᐯ","ᗯ","᙭","Y","ᘔ","ᗩ","ᗷ","ᑕ","ᗪ","E","ᖴ","G","ᕼ","I","ᒍ","K","ᒪ","ᗰ","ᑎ","O","ᑭ","ᑫ","ᖇ","ᔕ","T","ᑌ","ᐯ","ᗯ","᙭","Y","ᘔ"," ","0","1","2","3","4","5","6","7","8","9","!","$","%","&",",","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_","`","{","|","}","~"),
36
-
37
- "weird2": ("ᗩ","ᗷ","ᑢ","ᕲ","ᘿ","ᖴ","ᘜ","ᕼ","ᓰ","ᒚ","ᖽᐸ","ᒪ","ᘻ","ᘉ","ᓍ","ᕵ","ᕴ","ᖇ","S","ᖶ","ᑘ","ᐺ","ᘺ","᙭","ᖻ","ᗱ","ᗩ","ᗷ","ᑢ","ᕲ","ᘿ","ᖴ","ᘜ","ᕼ","ᓰ","ᒚ","ᖽᐸ","ᒪ","ᘻ","ᘉ","ᓍ","ᕵ","ᕴ","ᖇ","S","ᖶ","ᑘ","ᐺ","ᘺ","᙭","ᖻ","ᗱ"," ","0","1","2","3","4","5","6","7","8","9","!","$","%","&",",","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_","`","{","|","}","~"),
38
-
39
- "japanese":("卂","乃","匚","ᗪ","乇","千","Ꮆ","卄","丨","フ","Ҝ","ㄥ","爪","几","ㄖ","卩","Ɋ","尺","丂","ㄒ","ㄩ","ᐯ","山","乂","ㄚ","乙","卂","乃","匚","ᗪ","乇","千","Ꮆ","卄","丨","フ","Ҝ","ㄥ","爪","几","ㄖ","卩","Ɋ","尺","丂","ㄒ","ㄩ","ᐯ","山","乂","ㄚ","乙"," ","0","1","2","3","4","5","6","7","8","9","!","$","%","&",",","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_","`","{","|","}","~"),
40
-
41
- "japanese2":("ム","乃","ᄃ","り","乇","キ","ム","ん","ノ","フ","ズ","レ","ᄊ","刀","の","ア","ゐ","尺","丂","イ","ひ","√","W","メ","リ","乙","ム","乃","ᄃ","り","乇","キ","ム","ん","ノ","フ","ズ","レ","ᄊ","刀","の","ア","ゐ","尺","丂","イ","ひ","√","W","メ","リ","乙"," ","0","1","2","3","4","5","6","7","8","9","!","$","%","&",",","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_","`","{","|","}","~"),
42
-
43
-
44
-
45
-
46
- }
47
-
48
- random_decorators = {
49
- "chess": ("♔","♕","♖","♗","♘","♙","♚,","♛","♜","♝","♞","♟"),
50
- "cards": ("♠","♡","♢","♣","♤","♥","♦","♧","☆","★")
51
- }
52
-
53
- decorators = {
54
- "barrier": ("『","』"),
55
- "barrier2": ("【","】"),
56
- "notes": ("·.¸¸.·♩♪♫" , "♫♪♩·.¸¸.·"),
57
- "single_notes": ("♪","♫"),
58
- "transcending":("¸.-•~¹°”ˆ˜¨'" , "'¨˜ˆ”°¹~•-.¸"),
59
- "star": (".•°¤*(¯`★´¯)*¤°", "°¤*(¯´★`¯)*¤°•."),
60
- "curly": ("∙∙·▫▫ᵒᴼᵒ▫ₒₒ▫ᵒᴼᵒ▫ₒₒ▫ᵒᴼᵒ" , "ᵒᴼᵒ▫ₒₒ▫ᵒᴼᵒ▫ₒₒ▫ᵒᴼᵒ▫▫·∙∙"), # TOO DAMN LONG
61
- "short_curly": ("·▫▫ᵒᴼᵒ▫ₒₒ" , "ₒₒ▫ᵒᴼᵒ▫▫·"), # better
62
- "flower": ("◦•●◉✿", "✿◉●•◦"),
63
- "dot": ("•´¯`•." , ".•´¯`•"),
64
- "hearts": ("❥", "❣❤"),
65
- "crystal": ("⧩⟡", "❖"),
66
- "rifle": ("˜”*°•.˜”*°•","•°*”˜.•°*”˜"),
67
- "short_rifle": ("˜”*°•.",".•°*”˜"),
68
- "brackets": ("⦑", "⦒"),
69
- "chess": (choice(random_decorators["chess"]), choice(random_decorators["chess"])),
70
- "cards": (choice(random_decorators["cards"]), choice(random_decorators["cards"])),
71
-
72
- }
73
-
74
-
75
-
76
- def Fonter(text, font, decorator=""):
77
- original = fonts["original"]
78
- fontedtext = []
79
- for letter in text:
80
- fontedtext.append(fonts[font][original.index(letter)] if letter in original else letter)
81
- result = "".join(fontedtext)
82
- if decorator == "":
83
- return result
84
- return f"{decorators[decorator][0]}{result}{decorators[decorator][1]}"
File without changes