nercone-modern 1.3.0__py3-none-any.whl → 1.4.5__py3-none-any.whl

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,38 @@
1
+ class ModernColor:
2
+ def ansi_color_by_code(color_code: int | str = 0):
3
+ return f"\033[{color_code}m"
4
+
5
+ def ansi_color(color_name: str = "reset"):
6
+ if color_name == "reset":
7
+ return ModernColor.ansi_color_by_code(0)
8
+ elif color_name == "black":
9
+ return ModernColor.ansi_color_by_code(30)
10
+ elif color_name == "red":
11
+ return ModernColor.ansi_color_by_code(31)
12
+ elif color_name == "green":
13
+ return ModernColor.ansi_color_by_code(32)
14
+ elif color_name == "yellow":
15
+ return ModernColor.ansi_color_by_code(33)
16
+ elif color_name == "blue":
17
+ return ModernColor.ansi_color_by_code(34)
18
+ elif color_name == "magenta":
19
+ return ModernColor.ansi_color_by_code(35)
20
+ elif color_name == "cyan":
21
+ return ModernColor.ansi_color_by_code(36)
22
+ elif color_name == "white":
23
+ return ModernColor.ansi_color_by_code(37)
24
+ elif color_name in ("gray", "grey"):
25
+ return ModernColor.ansi_color_by_code(90)
26
+ else:
27
+ return ""
28
+
29
+ RESET = "\033[0m"
30
+ BLACK = "\033[30m"
31
+ RED = "\033[31m"
32
+ GREEN = "\033[32m"
33
+ YELLOW = "\033[33m"
34
+ BLUE = "\033[34m"
35
+ MAGENTA = "\033[35m"
36
+ CYAN = "\033[36m"
37
+ WHITE = "\033[37m"
38
+ GRAY = "\033[90m"
nercone_modern/text.py ADDED
@@ -0,0 +1,24 @@
1
+ from typing import Union
2
+ from .color import ModernColor
3
+
4
+ class ModernText:
5
+ def __init__(self, content="", color: str = ModernColor.WHITE):
6
+ self.content = content
7
+ if not color.startswith("\033"):
8
+ color = getattr(ModernColor, color.upper(), ModernColor.WHITE)
9
+ self.color = color
10
+
11
+ def __add__(self, other: Union[str, "ModernText"]):
12
+ if isinstance(other, ModernText):
13
+ if self.color == other.color:
14
+ return ModernText(self.content + other.content, self.color)
15
+ else:
16
+ combined = f"{self.color}{self.content}{ModernColor.RESET}{other.color}{other.content}"
17
+ return ModernText(combined, ModernColor.RESET)
18
+ elif isinstance(other, str):
19
+ return ModernText(self.content + other, self.color)
20
+ else:
21
+ raise TypeError(f"Unsupported operand type(s) for +: 'ModernText' and '{type(other).__name__}'")
22
+
23
+ def __str__(self):
24
+ return f"{self.color}{self.content}{ModernColor.RESET}"
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: nercone-modern
3
- Version: 1.3.0
4
- Summary: Modern Logging and Progress Bar Library
3
+ Version: 1.4.5
4
+ Summary: Modern CLI Library
5
5
  Author: Nercone
6
6
  Author-email: Nercone <nercone@diamondgotcat.net>
7
7
  License: MIT
@@ -16,7 +16,7 @@ Description-Content-Type: text/markdown
16
16
  <img width="1920" alt="Nercone Modern" src="https://github.com/user-attachments/assets/c92b0407-916f-46ec-9116-c3388b38c88c" />
17
17
 
18
18
  # nercone-modern
19
- Modern Logging and Progress Bar Library
19
+ Modern CLI Library
20
20
 
21
21
  ## Installation
22
22
 
@@ -38,28 +38,63 @@ pip3 install nercone-modern
38
38
 
39
39
  ## Usage
40
40
 
41
- **Import**
41
+ ### Import
42
42
 
43
43
  ```python
44
+ from nercone_modern.color import ModernColor
45
+ from nercone_modern.text import ModernText
44
46
  from nercone_modern.logging import ModernLogging
45
47
  from nercone_modern.progressbar import ModernProgressBar
46
48
  ```
47
49
 
48
- **Logging**
50
+ ### Color
51
+ ```python
52
+ from nercone_modern.color import ModernColor as Color
53
+ print(f"Build {Color.GREEN}Success{Color.RESET}")
54
+ ```
55
+
56
+ **Supported colors:**
57
+ - `CYAN`
58
+ - `MAGENTA`
59
+ - `YELLOW`
60
+ - `GREEN`
61
+ - `RED`
62
+ - `BLUE`
63
+ - `WHITE`
64
+ - `BLACK`
65
+ - `GRAY`
66
+ - `RESET`
67
+
68
+ ### Text
69
+ ```python
70
+ from nercone_modern.text import ModernText as Text
71
+ from nercone_modern.color import ModernColor as Color
72
+ print("Build" + Text("Success", color="green"))
73
+ print("Build" + Text("Failed", color=Color.RED))
74
+ ```
49
75
 
76
+ ### Logging
50
77
  ```python
78
+ from nercone_modern.logging import ModernLogging
51
79
  logger = ModernLogging("Main", display_level="DEBUG")
52
80
  logger.log("This is a test message", level="INFO")
53
81
  answer = logger.prompt("What's your name?", level="INFO")
54
82
  logger.log(f"Answer: {answer}", level="DEBUG")
55
83
  ```
56
84
 
57
- **Progress Bar**
85
+ **Supported levels:**
86
+ - `DEBUG`
87
+ - `INFO`
88
+ - `WARN`
89
+ - `ERROR`
90
+ - `CRITICAL`
58
91
 
92
+ ### Progress Bar
59
93
  ```python
94
+ from nercone_modern.progressbar import ModernProgressBar
60
95
  progress_bar = ModernProgressBar(total=100, process_name="Task 1", spinner_mode=True)
61
- progress_bar.start()
62
96
 
97
+ progress_bar.start()
63
98
  time.sleep(5)
64
99
 
65
100
  progress_bar.spinner(False)
@@ -1,7 +1,9 @@
1
1
  nercone_modern/__init__.py,sha256=ArF3T8FdWIhwGcL4MfYcHqMse3n5gjuyzbLNlcqRcxs,443
2
2
  nercone_modern/__main__.py,sha256=wKQnrGpTKemaaMv1oow_KKQFfPqxzhkz4KAhWBjVcYg,1957
3
+ nercone_modern/color.py,sha256=sy7f0Fe07PZWNfM1AOt7HeuhF7uGK2_IuZHEckwgxc4,1328
3
4
  nercone_modern/logging.py,sha256=p9biozctXNQmesChmn8ozCUKwBSC_5mdelCgbuZ3q0M,4945
4
5
  nercone_modern/progressbar.py,sha256=bzlGg0dSj88eli2lM0cI4xTw2FNJqlJb352jdtJbsWQ,8088
5
- nercone_modern-1.3.0.dist-info/WHEEL,sha256=5w2T7AS2mz1-rW9CNagNYWRCaB0iQqBMYLwKdlgiR4Q,78
6
- nercone_modern-1.3.0.dist-info/METADATA,sha256=ud_YpKj5z4UVcTcaD34R5LcFOkwivtMRtc9n_zQwMs0,1772
7
- nercone_modern-1.3.0.dist-info/RECORD,,
6
+ nercone_modern/text.py,sha256=eGxGQOJ3b-783ocLibkG62cOcYD4HLG_3diA52tU8jI,1031
7
+ nercone_modern-1.4.5.dist-info/WHEEL,sha256=5w2T7AS2mz1-rW9CNagNYWRCaB0iQqBMYLwKdlgiR4Q,78
8
+ nercone_modern-1.4.5.dist-info/METADATA,sha256=jZPhPnjGBngxi4j_NgDVtFeiZKaedAmJcaPhXTn7CWY,2472
9
+ nercone_modern-1.4.5.dist-info/RECORD,,