printyful 1.0__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.
- printyful-1.0/PKG-INFO +3 -0
- printyful-1.0/README.md +270 -0
- printyful-1.0/printyful/__init__.py +1 -0
- printyful-1.0/printyful/motors.py +98 -0
- printyful-1.0/printyful.egg-info/PKG-INFO +3 -0
- printyful-1.0/printyful.egg-info/SOURCES.txt +8 -0
- printyful-1.0/printyful.egg-info/dependency_links.txt +1 -0
- printyful-1.0/printyful.egg-info/top_level.txt +1 -0
- printyful-1.0/setup.cfg +4 -0
- printyful-1.0/setup.py +8 -0
printyful-1.0/PKG-INFO
ADDED
printyful-1.0/README.md
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# PRINTYFUL - You CLI application more beatiful!
|
|
2
|
+
|
|
3
|
+
Developed to improve the user experience in Python terminal applications, seeking simplicity of use and efficiency of applying beautiful decorations and loading screens to your application!
|
|
4
|
+
|
|
5
|
+
## How to use
|
|
6
|
+
Printyful is based on execution engines, where each engine has its own responsibility (inheriting executions from other engines) and is included in a final engine called FullMotor. Using this engine it will be possible to create decorated titles, panels, loading screens and other currently available decorations.
|
|
7
|
+
|
|
8
|
+
**Usage example:**
|
|
9
|
+
```
|
|
10
|
+
from printyful import FullMotor
|
|
11
|
+
|
|
12
|
+
motor = FullMotor()
|
|
13
|
+
|
|
14
|
+
title = motor.panel_title('Your life is great')
|
|
15
|
+
print(title)
|
|
16
|
+
|
|
17
|
+
motor.loading_bar(message='Downloading...', sleeptime=0.4 , final_text='100% (COMPLETE)')
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Available Motors
|
|
21
|
+
|
|
22
|
+
### 1. ColorMotor
|
|
23
|
+
|
|
24
|
+
Responsible for styling terminal text using ANSI color codes.
|
|
25
|
+
|
|
26
|
+
| Method | Description |
|
|
27
|
+
|---|---|
|
|
28
|
+
| `red_text(text)` | Displays text in red. |
|
|
29
|
+
| `blue_text(text)` | Displays text in blue. |
|
|
30
|
+
| `green_text(text)` | Displays text in green. |
|
|
31
|
+
| `yellow_text(text)` | Displays text in yellow. |
|
|
32
|
+
|
|
33
|
+
**Example:**
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from printyful import ColorMotor
|
|
37
|
+
|
|
38
|
+
color = ColorMotor()
|
|
39
|
+
|
|
40
|
+
print(color.red_text("Error!"))
|
|
41
|
+
print(color.green_text("Operation successful!"))
|
|
42
|
+
print(color.blue_text("Information"))
|
|
43
|
+
print(color.yellow_text("Warning!"))
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. BackgroudColorMotor
|
|
47
|
+
|
|
48
|
+
Inherits all features from `ColorMotor` and adds methods for applying background colors to terminal text.
|
|
49
|
+
|
|
50
|
+
| Method | Description |
|
|
51
|
+
|---|---|
|
|
52
|
+
| `red_background(text)` | Applies a red background. |
|
|
53
|
+
| `blue_background(text)` | Applies a blue background. |
|
|
54
|
+
| `green_background(text)` | Applies a green background. |
|
|
55
|
+
| `yellow_text(text)` | Applies a yellow background. |
|
|
56
|
+
|
|
57
|
+
**Example:**
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from printyful import BackgroudColorMotor
|
|
61
|
+
|
|
62
|
+
background = BackgroudColorMotor()
|
|
63
|
+
|
|
64
|
+
print(background.red_background(" ERROR "))
|
|
65
|
+
print(background.green_background(" SUCCESS "))
|
|
66
|
+
print(background.blue_background(" INFO "))
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 3. StylesMotor
|
|
70
|
+
|
|
71
|
+
Inherits the previous motors and introduces additional text formatting options.
|
|
72
|
+
|
|
73
|
+
| Method | Description |
|
|
74
|
+
|---|---|
|
|
75
|
+
| `bold_text(text)` | Makes text bold. |
|
|
76
|
+
| `sublime_text(text)` | Underlines text. |
|
|
77
|
+
| `invert_text(text)` | Inverts text and background colors. |
|
|
78
|
+
|
|
79
|
+
**Example:**
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from printyful import StylesMotor
|
|
83
|
+
|
|
84
|
+
styles = StylesMotor()
|
|
85
|
+
|
|
86
|
+
print(styles.bold_text("Important message"))
|
|
87
|
+
print(styles.sublime_text("Underlined text"))
|
|
88
|
+
print(styles.invert_text("Inverted text"))
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 4. PanelMotor
|
|
92
|
+
|
|
93
|
+
Responsible for creating visual panels and option lists directly in the terminal.
|
|
94
|
+
|
|
95
|
+
**Initialization parameter:**
|
|
96
|
+
|
|
97
|
+
| Parameter | Type | Default | Description |
|
|
98
|
+
|---|---|---|---|
|
|
99
|
+
| `title_color` | `str` | `'0'` | ANSI color code used for panel titles. |
|
|
100
|
+
|
|
101
|
+
**Methods:**
|
|
102
|
+
|
|
103
|
+
| Method | Description |
|
|
104
|
+
|---|---|
|
|
105
|
+
| `panel_title(title)` | Creates a visual panel containing a title. Requires at least 8 characters. |
|
|
106
|
+
| `panel_list_options_enumerated(options)` | Generates an automatically numbered option list. |
|
|
107
|
+
| `panel_list_options(options)` | Generates an option list with custom identifiers. |
|
|
108
|
+
|
|
109
|
+
**Example:**
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from printyful import PanelMotor
|
|
113
|
+
|
|
114
|
+
panel = PanelMotor(title_color='34')
|
|
115
|
+
|
|
116
|
+
print(panel.panel_title("PRINTYFUL"))
|
|
117
|
+
|
|
118
|
+
options = ["Start", "Settings", "Exit"]
|
|
119
|
+
print(panel.panel_list_options_enumerated(options))
|
|
120
|
+
|
|
121
|
+
custom_options = [
|
|
122
|
+
("A", "Start"),
|
|
123
|
+
("B", "Settings"),
|
|
124
|
+
("C", "Exit")
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
print(panel.panel_list_options(custom_options))
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 5. LoadingMotor
|
|
131
|
+
|
|
132
|
+
Inherits all previous functionalities and introduces loading animations for terminal applications.
|
|
133
|
+
|
|
134
|
+
**Method: `loading_text()`**
|
|
135
|
+
|
|
136
|
+
Displays a text-based loading animation using progressively increasing dots.
|
|
137
|
+
|
|
138
|
+
| Parameter | Type | Default | Description |
|
|
139
|
+
|---|---|---|---|
|
|
140
|
+
| `text` | `str` | `'Loading'` | Text displayed during the animation. |
|
|
141
|
+
| `multiplier` | `int` | `3` | Maximum number of dots. |
|
|
142
|
+
| `sleeptime` | `float` | `0.8` | Time interval between updates, in seconds. |
|
|
143
|
+
| `await_confirm` | `bool` | `False` | Waits for user confirmation after completion. |
|
|
144
|
+
|
|
145
|
+
**Example:**
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
from printyful import LoadingMotor
|
|
149
|
+
|
|
150
|
+
loading = LoadingMotor()
|
|
151
|
+
|
|
152
|
+
loading.loading_text(
|
|
153
|
+
text="Initializing",
|
|
154
|
+
multiplier=5,
|
|
155
|
+
sleeptime=0.5,
|
|
156
|
+
await_confirm=True
|
|
157
|
+
)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Method: `loading_bar()`**
|
|
161
|
+
|
|
162
|
+
Creates a percentage-based loading bar with dynamically changing colors.
|
|
163
|
+
|
|
164
|
+
| Parameter | Type | Default | Description |
|
|
165
|
+
|---|---|---|---|
|
|
166
|
+
| `multiplier` | `int` | `100` | Maximum progress value. |
|
|
167
|
+
| `sleeptime` | `float` | `0.8` | Time interval between updates. |
|
|
168
|
+
| `colors` | `List[str]` | `['31', '33', '32']` | ANSI color codes used by the progress bar. |
|
|
169
|
+
| `await_confirm` | `bool` | `False` | Waits for user confirmation after completion. |
|
|
170
|
+
| `final_text` | `str` | `''` | Additional text displayed beside the progress bar. |
|
|
171
|
+
| `message` | `str` | `''` | Message displayed during the loading process. |
|
|
172
|
+
|
|
173
|
+
Color transitions are determined by the current progress:
|
|
174
|
+
|
|
175
|
+
- 0%–49%: First color.
|
|
176
|
+
- 50%–79%: Second color.
|
|
177
|
+
- 80%–100%: Third color.
|
|
178
|
+
|
|
179
|
+
**Example:**
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
from printyful import LoadingMotor
|
|
183
|
+
|
|
184
|
+
loading = LoadingMotor()
|
|
185
|
+
|
|
186
|
+
loading.loading_bar(
|
|
187
|
+
multiplier=100,
|
|
188
|
+
sleeptime=0.05,
|
|
189
|
+
colors=['31', '33', '32'],
|
|
190
|
+
message="Installing dependencies...",
|
|
191
|
+
final_text="Installation",
|
|
192
|
+
await_confirm=True
|
|
193
|
+
)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### 6. FullMotor
|
|
197
|
+
|
|
198
|
+
`FullMotor` combines all previously introduced motors into a single class.
|
|
199
|
+
|
|
200
|
+
It is the most complete option in the library, providing access to text colors, background colors, formatting, panels, and loading animations through a single instance.
|
|
201
|
+
|
|
202
|
+
**Initialization parameter:**
|
|
203
|
+
|
|
204
|
+
| Parameter | Type | Default | Description |
|
|
205
|
+
|---|---|---|---|
|
|
206
|
+
| `title_color` | `str` | `'0'` | ANSI color code used for panel titles. |
|
|
207
|
+
|
|
208
|
+
**Example:**
|
|
209
|
+
|
|
210
|
+
```python
|
|
211
|
+
from printyful import FullMotor
|
|
212
|
+
|
|
213
|
+
motor = FullMotor(title_color='34')
|
|
214
|
+
|
|
215
|
+
# Text colors
|
|
216
|
+
print(motor.red_text("Error"))
|
|
217
|
+
print(motor.green_text("Success"))
|
|
218
|
+
|
|
219
|
+
# Background colors
|
|
220
|
+
print(motor.blue_background("Information"))
|
|
221
|
+
|
|
222
|
+
# Text styles
|
|
223
|
+
print(motor.bold_text("Important"))
|
|
224
|
+
|
|
225
|
+
# Panels
|
|
226
|
+
print(motor.panel_title("MY APPLICATION"))
|
|
227
|
+
|
|
228
|
+
# Loading animations
|
|
229
|
+
motor.loading_text("Starting", sleeptime=0.3)
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Motor Inheritance Structure
|
|
233
|
+
|
|
234
|
+
Printyful uses an inheritance-based architecture, allowing each motor to reuse and extend the functionalities of its predecessor.
|
|
235
|
+
|
|
236
|
+
```text
|
|
237
|
+
ColorMotor
|
|
238
|
+
|
|
|
239
|
+
v
|
|
240
|
+
BackgroudColorMotor
|
|
241
|
+
|
|
|
242
|
+
v
|
|
243
|
+
StylesMotor
|
|
244
|
+
|
|
|
245
|
+
v
|
|
246
|
+
PanelMotor
|
|
247
|
+
|
|
|
248
|
+
v
|
|
249
|
+
LoadingMotor
|
|
250
|
+
|
|
|
251
|
+
v
|
|
252
|
+
FullMotor
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Installation
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
pip install printyful
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Additional Notes
|
|
262
|
+
|
|
263
|
+
- Colors and text formatting are implemented using ANSI escape sequences.
|
|
264
|
+
- Loading animations use `time.sleep()` to control animation speed.
|
|
265
|
+
- Terminal clearing uses the `clear` command, primarily targeting Linux and Unix environments.
|
|
266
|
+
- Each motor can be imported and instantiated independently. Using `FullMotor` is optional.
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
**Printyful** — Make your terminal more expressive.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from printyful.motors import FullMotor
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
import time, os
|
|
3
|
+
|
|
4
|
+
class ColorMotor:
|
|
5
|
+
def red_text(self, text: str) -> str:
|
|
6
|
+
return f'\033[31m{text}\033[m'
|
|
7
|
+
|
|
8
|
+
def blue_text(self, text: str) -> str:
|
|
9
|
+
return f'\033[34m{text}\033[m'
|
|
10
|
+
|
|
11
|
+
def green_text(self, text: str) -> str:
|
|
12
|
+
return f'\033[32m{text}\033[m'
|
|
13
|
+
|
|
14
|
+
def yellow_text(self, text: str) -> str:
|
|
15
|
+
return f'\033[33m{text}\033[m'
|
|
16
|
+
|
|
17
|
+
class BackgroudColorMotor(ColorMotor):
|
|
18
|
+
def red_background(self, text: str) -> str:
|
|
19
|
+
return f'\033[41m {text} \033[0m'
|
|
20
|
+
|
|
21
|
+
def blue_background(self, text: str) -> str:
|
|
22
|
+
return f'\033[44m {text} \033[0m'
|
|
23
|
+
|
|
24
|
+
def green_background(self, text: str) -> str:
|
|
25
|
+
return f'\033[42m {text} \033[0m'
|
|
26
|
+
|
|
27
|
+
def yellow_text(self, text: str) -> str:
|
|
28
|
+
return f'\033[43m {text} \033[0m'
|
|
29
|
+
|
|
30
|
+
class StylesMotor(BackgroudColorMotor):
|
|
31
|
+
def bold_text(self, text: str) -> str:
|
|
32
|
+
return f'\033[1m {text} \033[0m'
|
|
33
|
+
|
|
34
|
+
def sublime_text(self, text: str) -> str:
|
|
35
|
+
return f'\033[4m {text} \033[0m'
|
|
36
|
+
|
|
37
|
+
def invert_text(self, text: str) -> str:
|
|
38
|
+
return f'\033[7m {text} \033[0m'
|
|
39
|
+
|
|
40
|
+
class PanelMotor(StylesMotor):
|
|
41
|
+
def __init__(self, title_color: str = '0'):
|
|
42
|
+
self.title_color = title_color
|
|
43
|
+
|
|
44
|
+
def panel_title(self, title: str) -> str:
|
|
45
|
+
if len(title) < 7:
|
|
46
|
+
raise ValueError('Insert 8 or more caracters on arg title!')
|
|
47
|
+
|
|
48
|
+
return f"""\033[{self.title_color}m
|
|
49
|
+
{'-'*((len(title)*2)+2)}
|
|
50
|
+
|{' '*(len(title)*2)}|
|
|
51
|
+
|{' '*(len(title)*2)}|
|
|
52
|
+
|{' '*(len(title)//2)}{title.strip()}{' '*(len(title)//2)}|
|
|
53
|
+
|{' '*(len(title)*2)}|
|
|
54
|
+
|{' '*(len(title)*2)}|
|
|
55
|
+
{'-'*((len(title)*2)+2)}
|
|
56
|
+
\033[{self.title_color if self.title_color != '0' else ''}m
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
def panel_list_options_enumerated(self, options: List[str]) -> str:
|
|
60
|
+
text = ''
|
|
61
|
+
for _, option in enumerate(options):
|
|
62
|
+
text += f' {_}. {option.upper()}\n'
|
|
63
|
+
|
|
64
|
+
return text
|
|
65
|
+
|
|
66
|
+
def panel_list_options(self, options: List[tuple]) -> str:
|
|
67
|
+
text = ''
|
|
68
|
+
for option in options:
|
|
69
|
+
identifier, char = option
|
|
70
|
+
text += f' {identifier}. {char}\n'
|
|
71
|
+
|
|
72
|
+
return text
|
|
73
|
+
|
|
74
|
+
class LoadingMotor(PanelMotor):
|
|
75
|
+
def loading_text(self, text: str = 'Loading', multiplier: int = 3, sleeptime: float = 0.8, await_confirm: bool = False) -> None:
|
|
76
|
+
for i in range(0, multiplier+1):
|
|
77
|
+
print(f'{text}' + f'{'.'*i}')
|
|
78
|
+
time.sleep(sleeptime)
|
|
79
|
+
os.system('clear')
|
|
80
|
+
|
|
81
|
+
if await_confirm:
|
|
82
|
+
input('Sucessful! Press ENTER to continue.')
|
|
83
|
+
|
|
84
|
+
def loading_bar(self, multiplier: int = 100, sleeptime: float = 0.8, colors: List[str] = ['31', '33', '32'], await_confirm: bool = False, final_text: str = '', message: str = '') -> None:
|
|
85
|
+
for i in range(0, multiplier+1):
|
|
86
|
+
if message:
|
|
87
|
+
print(message)
|
|
88
|
+
|
|
89
|
+
print(f'{i}% | {f'\033[{colors[0]}m=\033[0m'*i if i < 50 else f'\033[{colors[1]}m=\033[0m'*i if i < 80 else f'\033[{colors[2]}m=\033[0m'*i} {' '*(multiplier-i)}| {final_text}')
|
|
90
|
+
time.sleep(sleeptime)
|
|
91
|
+
os.system('clear')
|
|
92
|
+
|
|
93
|
+
if await_confirm:
|
|
94
|
+
input('Sucessful! Press ENTER to continue.')
|
|
95
|
+
|
|
96
|
+
class FullMotor(LoadingMotor):
|
|
97
|
+
def __init__(self, title_color = '0'):
|
|
98
|
+
super().__init__(title_color)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
printyful
|
printyful-1.0/setup.cfg
ADDED