step-printer 0.1.0__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.
step_printer/__init__.py
ADDED
step_printer/logger.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from rich import print
|
|
2
|
+
|
|
3
|
+
current = 1
|
|
4
|
+
|
|
5
|
+
def reset_current_step():
|
|
6
|
+
global current
|
|
7
|
+
current = 1
|
|
8
|
+
|
|
9
|
+
def step(text, config=None):
|
|
10
|
+
global current
|
|
11
|
+
|
|
12
|
+
if config is not None and not isinstance(config, dict):
|
|
13
|
+
raise TypeError("Config must be a dictionary")
|
|
14
|
+
|
|
15
|
+
with_step = config['with_step'] if config is not None and 'with_step' in config else True
|
|
16
|
+
status = config['status'] if config is not None and 'status' in config else 'info'
|
|
17
|
+
|
|
18
|
+
inside_bracket_text = current if with_step else '-'
|
|
19
|
+
text_color = color(status)
|
|
20
|
+
|
|
21
|
+
print(text_color['start'] + ("[" + str(inside_bracket_text) + "] ") + text + text_color['end'])
|
|
22
|
+
|
|
23
|
+
if with_step:
|
|
24
|
+
current += 1
|
|
25
|
+
|
|
26
|
+
def color(status):
|
|
27
|
+
statuses = {
|
|
28
|
+
'info': {'start': '[blue]', 'end': '[/blue]'},
|
|
29
|
+
'success': {'start': '[green]', 'end': '[/green]'},
|
|
30
|
+
'warning': {'start': '[yellow]', 'end': '[/yellow]'},
|
|
31
|
+
'error': {'start': '[red]', 'end': '[/red]'},
|
|
32
|
+
}
|
|
33
|
+
return statuses[status] if status in statuses else {'start': '[blue]', 'end': '[/blue]'}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: step-printer
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Reusable colored step logger powered by Rich
|
|
5
|
+
Author-email: Yosua Yerikho <yosua.yerikho123@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Requires-Dist: rich>=14.3.3
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
# step-printer
|
|
12
|
+
|
|
13
|
+
A lightweight Python utility for printing numbered, color-coded terminal steps powered by [Rich](https://github.com).
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install step-printer
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from step_printer import step, reset_current_step
|
|
25
|
+
|
|
26
|
+
# Default step (increments counter, blue info color)
|
|
27
|
+
step("Initializing application...")
|
|
28
|
+
|
|
29
|
+
# Custom status colors
|
|
30
|
+
step("Configuration loaded", {"status": "success"})
|
|
31
|
+
step("Cache miss, fetching fresh data", {"status": "warning"})
|
|
32
|
+
step("Failed to connect to secondary server", {"status": "error"})
|
|
33
|
+
|
|
34
|
+
# Print a message without incrementing the step counter (shows [-])
|
|
35
|
+
step("Additional details without a step number", {"with_step": False})
|
|
36
|
+
|
|
37
|
+
# Reset the counter back to 1
|
|
38
|
+
reset_current_step()
|
|
39
|
+
step("Starting new workflow")
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Configuration Options
|
|
43
|
+
|
|
44
|
+
Pass an optional dictionary as the second argument to `step(text, config)`:
|
|
45
|
+
|
|
46
|
+
| Key | Type | Default | Description |
|
|
47
|
+
| :--- | :--- | :--- | :--- |
|
|
48
|
+
| `status` | `str` | `"info"` | Text color preset: `"info"` (blue), `"success"` (green), `"warning"` (yellow), or `"error"` (red). |
|
|
49
|
+
| `with_step` | `bool` | `True` | If `True`, displays and increments `[1]`, `[2]`, etc. If `False`, displays `[-]` without incrementing. |
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
MIT License
|
|
54
|
+
|
|
55
|
+
Copyright (c) 2026 Yosua Yerikho
|
|
56
|
+
|
|
57
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
58
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
59
|
+
in the Software without restriction, including without limitation the rights
|
|
60
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
61
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
62
|
+
furnished to do so, subject to the following conditions:
|
|
63
|
+
|
|
64
|
+
The above copyright notice and this permission notice shall be included in all
|
|
65
|
+
copies or substantial portions of the Software.
|
|
66
|
+
|
|
67
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
68
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
69
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
70
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
71
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
72
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
73
|
+
SOFTWARE.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
step_printer/__init__.py,sha256=1KZWKQ54oziMn7ElEO6n-7jhRrfYduMQ0PV6usOhAZk,87
|
|
2
|
+
step_printer/logger.py,sha256=P_KKiqw5HFNo1pBZQZ1tzaFMGItVqtCViUacujE2g7k,1041
|
|
3
|
+
step_printer-0.1.0.dist-info/METADATA,sha256=bJal4UZ0wCZaLRtSWElLzOs5I0r51O0XWQhH240KFE4,2582
|
|
4
|
+
step_printer-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
5
|
+
step_printer-0.1.0.dist-info/RECORD,,
|