printcolored 2.0__tar.gz → 2.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.
- printcolored-2.0.1/PKG-INFO +4 -0
- {printcolored-2.0 → printcolored-2.0.1}/printColored/core.py +31 -9
- printcolored-2.0.1/printcolored.egg-info/PKG-INFO +4 -0
- {printcolored-2.0 → printcolored-2.0.1}/printcolored.egg-info/SOURCES.txt +1 -0
- printcolored-2.0.1/printcolored.egg-info/requires.txt +1 -0
- printcolored-2.0.1/pyproject.toml +8 -0
- printcolored-2.0/PKG-INFO +0 -3
- printcolored-2.0/printcolored.egg-info/PKG-INFO +0 -3
- printcolored-2.0/pyproject.toml +0 -7
- {printcolored-2.0 → printcolored-2.0.1}/printColored/Fonter.py +0 -0
- {printcolored-2.0 → printcolored-2.0.1}/printColored/__init__.py +0 -0
- {printcolored-2.0 → printcolored-2.0.1}/printColored/__main__.py +0 -0
- {printcolored-2.0 → printcolored-2.0.1}/printColored/formats.py +0 -0
- {printcolored-2.0 → printcolored-2.0.1}/printcolored.egg-info/dependency_links.txt +0 -0
- {printcolored-2.0 → printcolored-2.0.1}/printcolored.egg-info/top_level.txt +0 -0
- {printcolored-2.0 → printcolored-2.0.1}/setup.cfg +0 -0
|
@@ -11,13 +11,34 @@ except ImportError:
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
from pathlib import Path
|
|
14
|
-
from os.path import exists
|
|
15
14
|
import json
|
|
15
|
+
from platformdirs import user_config_dir
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
CONFIG_DIR = Path(user_config_dir("printColored"))
|
|
18
|
+
CUSTOM_FORMATS_PATH = CONFIG_DIR / "custom.json"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def load_custom_formats():
|
|
22
|
+
if CUSTOM_FORMATS_PATH.exists():
|
|
23
|
+
with open(CUSTOM_FORMATS_PATH, "r") as file:
|
|
24
|
+
return json.load(file)
|
|
25
|
+
return {}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def save_custom_formats(formats):
|
|
29
|
+
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
|
|
30
|
+
with open(CUSTOM_FORMATS_PATH, "w") as file:
|
|
31
|
+
json.dump(formats, file, indent=4)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def add_custom_format(name, value):
|
|
35
|
+
formats = load_custom_formats()
|
|
36
|
+
formats[name] = value
|
|
37
|
+
save_custom_formats(formats)
|
|
38
|
+
return formats
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
custom_formats = load_custom_formats()
|
|
21
42
|
|
|
22
43
|
|
|
23
44
|
from . import Fonter
|
|
@@ -71,8 +92,10 @@ def _build_code(*formats_used, html_view="", source_order=()):
|
|
|
71
92
|
return ";".join(code_list)
|
|
72
93
|
|
|
73
94
|
def _rgb_validation(r,g,b):
|
|
74
|
-
if r == ""
|
|
75
|
-
|
|
95
|
+
if r == "" and g == "" and b == "":
|
|
96
|
+
return ""
|
|
97
|
+
elif r == "" or g == "" or b == "":
|
|
98
|
+
raise ValueError("One or more RGB values are missing!")
|
|
76
99
|
elif not r.isdigit() or not g.isdigit() or not b.isdigit():
|
|
77
100
|
raise ValueError("You cant enter a non-digit!")
|
|
78
101
|
elif int(r) > 255 or int(r) < 0 or int(g) > 255 or int(g) < 0 or int(b) > 255 or int(b) < 0:
|
|
@@ -254,5 +277,4 @@ def formatfinder(min, max): # made this to find new formats, theres nothing beyo
|
|
|
254
277
|
print(f"{key}: {value}")
|
|
255
278
|
else:
|
|
256
279
|
for key, value in ansi_formats.items():
|
|
257
|
-
print(f"\033[{value}m{key}\033[0m")
|
|
258
|
-
|
|
280
|
+
print(f"\033[{value}m{key}\033[0m")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
platformdirs
|
printcolored-2.0/PKG-INFO
DELETED
printcolored-2.0/pyproject.toml
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|