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.
@@ -0,0 +1,4 @@
1
+ Metadata-Version: 2.4
2
+ Name: printcolored
3
+ Version: 2.0.1
4
+ Requires-Dist: platformdirs
@@ -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
- script_dir = Path(__file__).parent
18
- path = script_dir / "custom.json"
19
- with open(path, "r") as file:
20
- custom_formats = json.load(file)
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 == "" or g == "" or b == "":
75
- raise ValueError("You cant enter an empty value!")
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,4 @@
1
+ Metadata-Version: 2.4
2
+ Name: printcolored
3
+ Version: 2.0.1
4
+ Requires-Dist: platformdirs
@@ -7,4 +7,5 @@ printColored/formats.py
7
7
  printcolored.egg-info/PKG-INFO
8
8
  printcolored.egg-info/SOURCES.txt
9
9
  printcolored.egg-info/dependency_links.txt
10
+ printcolored.egg-info/requires.txt
10
11
  printcolored.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ platformdirs
@@ -0,0 +1,8 @@
1
+ [project]
2
+ name = "printcolored"
3
+ version = "2.0.1"
4
+ dependencies = ["platformdirs"]
5
+
6
+ [build-system]
7
+ requires = ["setuptools"]
8
+ build-backend = "setuptools.build_meta"
printcolored-2.0/PKG-INFO DELETED
@@ -1,3 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: printcolored
3
- Version: 2.0
@@ -1,3 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: printcolored
3
- Version: 2.0
@@ -1,7 +0,0 @@
1
- [project]
2
- name = "printcolored"
3
- version = "2.0"
4
-
5
- [build-system]
6
- requires = ["setuptools"]
7
- build-backend = "setuptools.build_meta"
File without changes