Luci-Code-Tools 2.1.2__tar.gz → 2.1.4__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.
- {luci_code_tools-2.1.2 → luci_code_tools-2.1.4}/Luci_Code_Tools.egg-info/PKG-INFO +35 -28
- {luci_code_tools-2.1.2 → luci_code_tools-2.1.4}/Luci_code_tools.py +245 -249
- {luci_code_tools-2.1.2 → luci_code_tools-2.1.4}/PKG-INFO +35 -28
- {luci_code_tools-2.1.2 → luci_code_tools-2.1.4}/README.md +33 -26
- {luci_code_tools-2.1.2 → luci_code_tools-2.1.4}/setup.py +2 -2
- {luci_code_tools-2.1.2 → luci_code_tools-2.1.4}/LICENCE +0 -0
- {luci_code_tools-2.1.2 → luci_code_tools-2.1.4}/Luci_Code_Tools.egg-info/SOURCES.txt +0 -0
- {luci_code_tools-2.1.2 → luci_code_tools-2.1.4}/Luci_Code_Tools.egg-info/dependency_links.txt +0 -0
- {luci_code_tools-2.1.2 → luci_code_tools-2.1.4}/Luci_Code_Tools.egg-info/top_level.txt +0 -0
- {luci_code_tools-2.1.2 → luci_code_tools-2.1.4}/setup.cfg +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Luci-Code-Tools
|
|
3
|
-
Version: 2.1.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 2.1.4
|
|
4
|
+
Summary: 一个简单的工具库 / A Eazy Tools Module
|
|
5
5
|
Home-page: https://github.com/Luci-Codeing/code_tools
|
|
6
6
|
Author: Luci_Code
|
|
7
7
|
Author-email: 3967742419@qq.com
|
|
@@ -20,7 +20,7 @@ Dynamic: license-file
|
|
|
20
20
|
Dynamic: requires-python
|
|
21
21
|
Dynamic: summary
|
|
22
22
|
|
|
23
|
-
[](https://pypi.org/project/Luci_Code_Tools/)
|
|
24
24
|
|
|
25
25
|
[]()
|
|
26
26
|
|
|
@@ -118,8 +118,8 @@ MIT Licence (c) Luci_Code
|
|
|
118
118
|
|
|
119
119
|
| 函数名 | 功能 | 参数列表 |
|
|
120
120
|
| --- | --- | --- |
|
|
121
|
-
| color_rgb | 输出真彩色文本, 支持 rgb 调色 | data, r, g, b,
|
|
122
|
-
| color | 输出 ANSI 转义序列固定颜色, 适合不会调色的开发者 | data, text_color, bg_color, mode,
|
|
121
|
+
| color_rgb | 输出真彩色文本, 支持 rgb 调色 | data, r, g, b, line |
|
|
122
|
+
| color | 输出 ANSI 转义序列固定颜色, 适合不会调色的开发者 | data, text_color, bg_color, mode, line |
|
|
123
123
|
| clear_screen | 在任意系统下都能清屏的函数 | 无参数 |
|
|
124
124
|
| safe_input | 让用户安全的输入字符串 | prompt, text_color, bg_color, mode |
|
|
125
125
|
| safe_int | 让用户安全的输入整数 | prompt, text_color, bg_color, mode |
|
|
@@ -129,27 +129,32 @@ MIT Licence (c) Luci_Code
|
|
|
129
129
|
|
|
130
130
|
# 参数使用教程
|
|
131
131
|
|
|
132
|
-
**
|
|
132
|
+
**line** 是指在原本的基础上再输出 ** {num} ** 行, 默认为 2 (多一行)
|
|
133
133
|
|
|
134
134
|
***输出效果:***
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
line = 1 : [
|
|
137
|
+
content1
|
|
138
|
+
content2
|
|
139
|
+
input: Luci
|
|
140
|
+
]
|
|
137
141
|
|
|
138
|
-
|
|
139
|
-
|
|
142
|
+
line = 2 : [
|
|
143
|
+
content1 (line = 1)
|
|
144
|
+
content2
|
|
140
145
|
|
|
141
|
-
input:
|
|
146
|
+
input: Luci
|
|
147
|
+
]
|
|
142
148
|
|
|
143
|
-
|
|
149
|
+
line = 3 : [
|
|
150
|
+
content1 (line = 1)
|
|
151
|
+
content2
|
|
144
152
|
|
|
145
|
-
- newline=False :
|
|
146
153
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
input: content
|
|
150
|
-
if-content-prompt
|
|
154
|
+
input: Luci
|
|
155
|
+
]
|
|
151
156
|
|
|
152
|
-
|
|
157
|
+
**这一改动让命令行的输出变得有辨识度**
|
|
153
158
|
|
|
154
159
|
**data, prompt** 都是 *输出的文本* 的意思
|
|
155
160
|
|
|
@@ -157,13 +162,13 @@ if-content-prompt
|
|
|
157
162
|
|
|
158
163
|
- **color_rgb**
|
|
159
164
|
|
|
160
|
-
**color_rgb** 的参数有: data, r, g, b,
|
|
165
|
+
**color_rgb** 的参数有: data, r, g, b, line
|
|
161
166
|
|
|
162
|
-
**其中**, data 是数据的意思, 代表输出的内容, [r, g, b] 是 ***标准 rgb 调色*** 的用处, 所以 [r, g, b] 分别填入 r, g, b 的值,
|
|
167
|
+
**其中**, data 是数据的意思, 代表输出的内容, [r, g, b] 是 ***标准 rgb 调色*** 的用处, 所以 [r, g, b] 分别填入 r, g, b 的值, line 不用讲解, 前面说了喵
|
|
163
168
|
|
|
164
169
|
- **color**
|
|
165
170
|
|
|
166
|
-
**color** 的参数有: data, text_color, bg_color, mode,
|
|
171
|
+
**color** 的参数有: data, text_color, bg_color, mode, line
|
|
167
172
|
|
|
168
173
|
**data** 和之前一样, ***[text_color, bg_color, mode]***, 这三个参数在 safe_\* 中也有, 意思相同, 暂不讲解, **text_color** 就是控制输出的文本的颜色**(前景色)**, bg_color** 是输出文本的**背景色**, **mode** 为输出的格式 **(显示方式)**, 这三个参数在最后会有**表格对照表**
|
|
169
174
|
|
|
@@ -259,6 +264,7 @@ if-content-prompt
|
|
|
259
264
|
# 制作者 & 感谢名单
|
|
260
265
|
|
|
261
266
|
| 制作 | 分工 |
|
|
267
|
+
| --- | --- |
|
|
262
268
|
| DeepSeek | 检查 |
|
|
263
269
|
| DeepSeek | 改进方法 |
|
|
264
270
|
| Luci_Code | 改进 |
|
|
@@ -371,8 +377,8 @@ MIT License (c) Luci_Code
|
|
|
371
377
|
|
|
372
378
|
| Function Name | Functionality | Parameter List |
|
|
373
379
|
| --- | --- | --- |
|
|
374
|
-
| color_rgb | Outputs true-color text; supports RGB color customization. | data, r, g, b,
|
|
375
|
-
| color | Outputs text using fixed ANSI escape sequence colors; suitable for developers unfamiliar with color mixing. | data, text_color, bg_color, mode,
|
|
380
|
+
| color_rgb | Outputs true-color text; supports RGB color customization. | data, r, g, b, line |
|
|
381
|
+
| color | Outputs text using fixed ANSI escape sequence colors; suitable for developers unfamiliar with color mixing. | data, text_color, bg_color, mode, line |
|
|
376
382
|
| clear_screen | A function that clears the screen on any operating system. | No parameters |
|
|
377
383
|
| safe_input | Safely prompts the user to input a string. | prompt, text_color, bg_color, mode |
|
|
378
384
|
| safe_int | Safely prompts the user to input an integer. | prompt, text_color, bg_color, mode |
|
|
@@ -382,11 +388,11 @@ MIT License (c) Luci_Code
|
|
|
382
388
|
|
|
383
389
|
# Parameter Usage Guide
|
|
384
390
|
|
|
385
|
-
**
|
|
391
|
+
**line** refers to whether an additional line break is added after the output; it defaults to `True` (adding an extra line).
|
|
386
392
|
|
|
387
393
|
***Output Effect:***
|
|
388
394
|
|
|
389
|
-
- `
|
|
395
|
+
- `line=True`:
|
|
390
396
|
|
|
391
397
|
content-1 (Here, this implies `False`)
|
|
392
398
|
content-2
|
|
@@ -395,7 +401,7 @@ input: content
|
|
|
395
401
|
|
|
396
402
|
if-content-prompt
|
|
397
403
|
|
|
398
|
-
- `
|
|
404
|
+
- `line=False`:
|
|
399
405
|
|
|
400
406
|
content-1
|
|
401
407
|
content-2
|
|
@@ -410,13 +416,13 @@ if-content-prompt
|
|
|
410
416
|
|
|
411
417
|
- **color_rgb**
|
|
412
418
|
|
|
413
|
-
The parameters for **color_rgb** are: data, r, g, b,
|
|
419
|
+
The parameters for **color_rgb** are: data, r, g, b, line.
|
|
414
420
|
|
|
415
|
-
**Specifically:** `data` refers to the actual content being output; `[r, g, b]` are used for ***standard RGB color mixing***—simply fill in the respective values for r, g, and b. The `
|
|
421
|
+
**Specifically:** `data` refers to the actual content being output; `[r, g, b]` are used for ***standard RGB color mixing***—simply fill in the respective values for r, g, and b. The `line` parameter requires no further explanation, as it was covered earlier!
|
|
416
422
|
|
|
417
423
|
- **color**
|
|
418
424
|
|
|
419
|
-
The parameters for **color** are: `data`, `text_color`, `bg_color`, `mode`, and `
|
|
425
|
+
The parameters for **color** are: `data`, `text_color`, `bg_color`, `mode`, and `line`.
|
|
420
426
|
|
|
421
427
|
**data**: As before, this takes the format `[text_color, bg_color, mode]`. These three parameters also appear in the `safe_*` functions with the same meanings, so we won't explain them again here. **text_color** controls the color of the output text (the **foreground color**); **bg_color** controls the **background color** of the output text; and **mode** specifies the output format (the **display style**). A **reference table** for these three parameters can be found at the end of this document.
|
|
422
428
|
|
|
@@ -512,6 +518,7 @@ The explanations for these two functions are essentially identical to that of **
|
|
|
512
518
|
# Credits & Acknowledgments
|
|
513
519
|
|
|
514
520
|
| Contributor | Role |
|
|
521
|
+
| --- | --- |
|
|
515
522
|
| DeepSeek | Review |
|
|
516
523
|
| DeepSeek | Method Improvement |
|
|
517
524
|
| Luci_Code | Improvements |
|
|
@@ -1,250 +1,246 @@
|
|
|
1
|
-
from sys import platform, exit
|
|
2
|
-
from subprocess import run
|
|
3
|
-
from typing import Optional, Union
|
|
4
|
-
import shutil
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if
|
|
23
|
-
parts.append(str(
|
|
24
|
-
if
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
print(_ansi_rgb(data, r, g, b, mode), end=
|
|
61
|
-
|
|
62
|
-
def color(data: str, text_color: Optional[int] = None, bg_color: Optional[int] = None, mode: int = 0,
|
|
63
|
-
""" 输出彩色字符到控制台
|
|
64
|
-
|
|
65
|
-
参数:
|
|
66
|
-
data: 要输出的文本内容
|
|
67
|
-
text_color: 前景色代码 (30-37普通色, 90-97亮色)
|
|
68
|
-
bg_color: 背景色代码 (40-47普通色, 100-107亮色)
|
|
69
|
-
mode: 显示方式 (0=默认,1=粗体,2=暗淡,3=斜体,4=下划线,5=闪烁,7=反色,8=隐藏,9=删除线)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
示例:
|
|
73
|
-
color("错误信息", text_color=31, mode=1) # 红色加粗
|
|
74
|
-
color("警告", text_color=33, bg_color=41) # 黄字红底
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
"""
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
return
|
|
217
|
-
|
|
218
|
-
def
|
|
219
|
-
"""
|
|
220
|
-
return _safe_number(prompt,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
print("\n===
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
name
|
|
245
|
-
|
|
246
|
-
height = safe_float("请输入身高(米) (Please Enter height (m)): ", text_color=34)
|
|
247
|
-
|
|
248
|
-
color(f"\n你好 {name}, 年龄 {age}, 身高 {height}m\nHello {name}, Age {age}, height {height}", text_color=32, mode=1)
|
|
249
|
-
|
|
1
|
+
from sys import platform, exit
|
|
2
|
+
from subprocess import run
|
|
3
|
+
from typing import Optional, Union
|
|
4
|
+
import shutil
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
if os.name == "nt": # 系统名称 = "nt" 为 Windows
|
|
8
|
+
os.system("") # 激活 win10 / win7 的终端彩色显示功能
|
|
9
|
+
|
|
10
|
+
__version__ = "2.1.4" # 明确版本号
|
|
11
|
+
__all__ = [
|
|
12
|
+
'color', 'color_rgb', 'clear_screen',
|
|
13
|
+
'safe_input', 'safe_int', 'safe_float'
|
|
14
|
+
] # 确定导出后的代码可用的函数
|
|
15
|
+
|
|
16
|
+
class _AnsiCode: # AnsiCode 类
|
|
17
|
+
ESC = "\033"
|
|
18
|
+
RESET = f"{ESC}[0m"
|
|
19
|
+
@staticmethod
|
|
20
|
+
def build(mode: int = 0, fg: Optional[int] = None, bg: Optional[int] = None) -> str:
|
|
21
|
+
parts = []
|
|
22
|
+
if mode != 0:
|
|
23
|
+
parts.append(str(mode))
|
|
24
|
+
if fg is not None:
|
|
25
|
+
parts.append(str(fg))
|
|
26
|
+
if bg is not None:
|
|
27
|
+
parts.append(str(bg))
|
|
28
|
+
if parts:
|
|
29
|
+
return f"{_AnsiCode.ESC}[{';'.join(parts)}m"
|
|
30
|
+
return ""
|
|
31
|
+
|
|
32
|
+
def _ansi_return(data: str, text_color: Optional[int] = None, bg_color: Optional[int] = None, mode: int = 0) -> str: # 6767676767 ! 🐱
|
|
33
|
+
""" 生成ANSI彩色文本(不自动输出)
|
|
34
|
+
|
|
35
|
+
参数:
|
|
36
|
+
data: 要着色的文本内容
|
|
37
|
+
text_color: 前景色代码 (30-37普通色, 90-97亮色)
|
|
38
|
+
bg_color: 背景色代码 (40-47普通色, 100-107亮色)
|
|
39
|
+
mode: 显示方式 (0=默认,1=粗体,2=暗淡,3=斜体,4=下划线,5=闪烁,7=反色,8=隐藏,9=删除线)
|
|
40
|
+
|
|
41
|
+
返回:
|
|
42
|
+
带ANSI转义序列的字符串
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
if text_color is None and bg_color is None: # 如果 text_color 和 bg_color 不是 None
|
|
46
|
+
return data
|
|
47
|
+
|
|
48
|
+
ansi = _AnsiCode.build(mode, text_color, bg_color)
|
|
49
|
+
return f"{ansi}{data}{_AnsiCode.RESET}"
|
|
50
|
+
|
|
51
|
+
def _ansi_rgb(data: str, r: int, g: int, b: int, mode: int = 0) -> str:
|
|
52
|
+
""" 内部函数 """
|
|
53
|
+
if mode == 0:
|
|
54
|
+
return f"{_AnsiCode.ESC}[38;2;{r};{g};{b}m{data}{_AnsiCode.RESET}"
|
|
55
|
+
else:
|
|
56
|
+
return f"{_AnsiCode.ESC}[{mode};38;2;{r};{g};{b}m{data}{_AnsiCode.RESET}"
|
|
57
|
+
|
|
58
|
+
def color_rgb(data: str, r: int, g: int, b: int, mode: int = 0, line: int = 2) -> None: # 用户输出 RGB 彩色字符
|
|
59
|
+
""" 输出 rgb 字符 """
|
|
60
|
+
print(_ansi_rgb(data, r, g, b, mode), end="\n" * line)
|
|
61
|
+
|
|
62
|
+
def color(data: str, text_color: Optional[int] = None, bg_color: Optional[int] = None, mode: int = 0, line: int = 2) -> None: # 🤔
|
|
63
|
+
""" 输出彩色字符到控制台
|
|
64
|
+
|
|
65
|
+
参数:
|
|
66
|
+
data: 要输出的文本内容
|
|
67
|
+
text_color: 前景色代码 (30-37普通色, 90-97亮色)
|
|
68
|
+
bg_color: 背景色代码 (40-47普通色, 100-107亮色)
|
|
69
|
+
mode: 显示方式 (0=默认,1=粗体,2=暗淡,3=斜体,4=下划线,5=闪烁,7=反色,8=隐藏,9=删除线)
|
|
70
|
+
line: 是否在输出后添加空行,默认 2 空行,0 = 无空行
|
|
71
|
+
|
|
72
|
+
示例:
|
|
73
|
+
color("错误信息", text_color=31, mode=1) # 红色加粗
|
|
74
|
+
color("警告", text_color=33, bg_color=41) # 黄字红底
|
|
75
|
+
|
|
76
|
+
line 参数说明:
|
|
77
|
+
line 函数填入 int 类型的数字, 填入几就输出几个空行(print自带一个, 但是你可以不用管print, end不带print自带的空行)
|
|
78
|
+
实现代码部分:
|
|
79
|
+
|
|
80
|
+
< python
|
|
81
|
+
print(_ansi_return(data, text_color, bg_color, mode), end="\n" * line)
|
|
82
|
+
>
|
|
83
|
+
|
|
84
|
+
end="\n" * line
|
|
85
|
+
比如:
|
|
86
|
+
line = 2
|
|
87
|
+
为"空行数 = 2"的意思
|
|
88
|
+
|
|
89
|
+
line = 2
|
|
90
|
+
output:
|
|
91
|
+
content1 (This is line = 1)
|
|
92
|
+
content2
|
|
93
|
+
|
|
94
|
+
input: Luci
|
|
95
|
+
|
|
96
|
+
line = 0
|
|
97
|
+
HelloWorld (Hello和World是两个字符串)
|
|
98
|
+
"""
|
|
99
|
+
print(_ansi_return(data, text_color, bg_color, mode), end="\n" * line)
|
|
100
|
+
|
|
101
|
+
def clear_screen() -> None: # 清屏: 兼容版
|
|
102
|
+
""" 跨平台兼容清屏 """
|
|
103
|
+
try: # 检测环境
|
|
104
|
+
if platform == "win32": # 环境为 Windows
|
|
105
|
+
run(['cmd', '/c', 'cls']) # 安全: 使用列表命令, 防注入
|
|
106
|
+
else: # 包括 MacOS, Linux (Android 也是 Linux 列)
|
|
107
|
+
run(['clear'], check=False) # check = 遇到错误我 自己来, 别报错
|
|
108
|
+
except Exception: # 非交互式环境 (.py 打包.exe类环境等没 有cmd命令的环境)
|
|
109
|
+
try: # 最后一道防线
|
|
110
|
+
print("\n" * shutil.get_terminal_size().lines) # 根据终端输出相对应空行
|
|
111
|
+
except: # 为了防止用户让终端的长度无法获取
|
|
112
|
+
print("\n" * 250) # 防止获取不到终端长度的输出
|
|
113
|
+
|
|
114
|
+
def _safe_try_except(prompt, input_type = True, convert_func=None, text_color=None, bg_color=None, mode=0) -> Union[str, int, float]: # True = input 模式 : False = int / float 模式
|
|
115
|
+
if text_color is not None or bg_color is not None:
|
|
116
|
+
prompt = _ansi_return(prompt, text_color, bg_color, mode)
|
|
117
|
+
while True:
|
|
118
|
+
try:
|
|
119
|
+
if input_type:
|
|
120
|
+
return input(prompt)
|
|
121
|
+
else:
|
|
122
|
+
return convert_func(input(prompt))
|
|
123
|
+
except MemoryError:
|
|
124
|
+
color("OUT OF MEMORY !\n\nInsufficient memory to complete the operation.\n\nTry:\n\n· Close other apps and retry\n· Increase RAM or swap space\n· Restart the system if problem persists\nOperation terminated. (Error 0x0000005E)\n\n内存不足!\n\n内存不足,无法完成操作。\n\n请尝试:\n\n· 关闭其他应用后重试\n· 增加内存或交换空间\n· 如果问题仍然存在,请重启系 统\n操作已终止 (错误代码 0x0000005E)", 37, 44, 1)
|
|
125
|
+
exit(1)
|
|
126
|
+
except ValueError:
|
|
127
|
+
print("Invalid input value type\n无效的输入值类型")
|
|
128
|
+
continue
|
|
129
|
+
except KeyboardInterrupt:
|
|
130
|
+
clear_screen()
|
|
131
|
+
color("Program interrupted\n程序被中断", 33, None, 1)
|
|
132
|
+
exit(0)
|
|
133
|
+
except EOFError:
|
|
134
|
+
clear_screen()
|
|
135
|
+
color("Input stream terminated\n输入流已终止", 33, None, 1)
|
|
136
|
+
exit(0)
|
|
137
|
+
except TimeoutError:
|
|
138
|
+
color("Input timeout\n输入超时", 33, None, 1)
|
|
139
|
+
exit(0)
|
|
140
|
+
except UnicodeDecodeError:
|
|
141
|
+
color("Unicode encoding error\nUnicode 编码错误", 33, None, 1)
|
|
142
|
+
continue
|
|
143
|
+
except OSError:
|
|
144
|
+
color("OSError: System operation failed. Please check file path, permissions, or disk space.\nOSError:系统操作失败。请检查文件路径、权限或磁盘空间。", 37, 44, 1)
|
|
145
|
+
exit(1)
|
|
146
|
+
except OverflowError:
|
|
147
|
+
color("Value overflow\n数值溢出", 33, None, 1)
|
|
148
|
+
continue
|
|
149
|
+
except TypeError:
|
|
150
|
+
color("Type conversion failed\n类型转换失败", 33, None, 1)
|
|
151
|
+
continue
|
|
152
|
+
except RuntimeError as e:
|
|
153
|
+
color(f"Serious runtime error\nError message:\n{e}\n严重的运行时错误\n错误信息,\n{e}", 33, None, 1)
|
|
154
|
+
exit(1)
|
|
155
|
+
except SystemExit:
|
|
156
|
+
color("System exit\n系统退出", 33, None, 1)
|
|
157
|
+
exit(0)
|
|
158
|
+
except SystemError:
|
|
159
|
+
color("System error, please check Python interpreter\n系统错误,请检查 Python 解释器", 33, None, 1)
|
|
160
|
+
exit(0)
|
|
161
|
+
except AttributeError:
|
|
162
|
+
color("Object has no such attribute\n对象没有此属性", 33, None, 1)
|
|
163
|
+
continue
|
|
164
|
+
except NameError:
|
|
165
|
+
color("Variable or function not defined\n变量或函数未定义", 33, None, 1)
|
|
166
|
+
exit(1)
|
|
167
|
+
except SyntaxError:
|
|
168
|
+
color("Syntax error in code\n代码中的语法错误", 33, None, 1)
|
|
169
|
+
continue
|
|
170
|
+
except RecursionError:
|
|
171
|
+
color("Recursion depth exceeded\n超出递归深度", 33, None, 1)
|
|
172
|
+
exit(1)
|
|
173
|
+
except BrokenPipeError:
|
|
174
|
+
color("Input pipe closed by other end\n输入管道被另一端关闭", 33, None, 1)
|
|
175
|
+
exit(1)
|
|
176
|
+
except ConnectionError:
|
|
177
|
+
color("Input from network stream and connection lost\n来自网络流的输入,连接已丢失", 33, None, 1)
|
|
178
|
+
exit(1)
|
|
179
|
+
except FileNotFoundError:
|
|
180
|
+
color("Input source file not found\n未找到输入源 文件", 33, None, 1)
|
|
181
|
+
exit(1)
|
|
182
|
+
except IsADirectoryError:
|
|
183
|
+
color("Input source is a directory, not a file\n 输入源是一个目录,而不是文件", 33, None, 1)
|
|
184
|
+
exit(1)
|
|
185
|
+
except PermissionError:
|
|
186
|
+
color("Permission denied to read input source\n权限被拒绝,无法读取输入源", 33, None, 1)
|
|
187
|
+
exit(1)
|
|
188
|
+
except BlockingIOError:
|
|
189
|
+
color("No data to read in non-blocking mode\n非阻塞模式下没有数据可读", 33, None, 1)
|
|
190
|
+
continue
|
|
191
|
+
except ChildProcessError:
|
|
192
|
+
color("Child process operation failed\n子进程操作失败", 33, None, 1)
|
|
193
|
+
exit(1)
|
|
194
|
+
except InterruptedError:
|
|
195
|
+
color("System call interrupted by signal\n系统调 用被信号中断", 33, None, 1)
|
|
196
|
+
continue
|
|
197
|
+
except StopIteration:
|
|
198
|
+
color("Custom iterator input exhausted\n自定义迭 代器输入已耗尽", 33, None, 1)
|
|
199
|
+
continue
|
|
200
|
+
except GeneratorExit:
|
|
201
|
+
color("Generator closed\n生成器已关闭", 33, None, 1)
|
|
202
|
+
continue
|
|
203
|
+
except Exception as e:
|
|
204
|
+
color(f"Code error\nError message:\n{e}\n代码错误\n错误信息:\n{e}", 33, None, 1)
|
|
205
|
+
continue
|
|
206
|
+
# 27 个 except
|
|
207
|
+
|
|
208
|
+
def safe_input(prompt, text_color=None, bg_color=None, mode=0) -> str:
|
|
209
|
+
return _safe_try_except(prompt, True, None, text_color, bg_color, mode)
|
|
210
|
+
|
|
211
|
+
def _safe_number(prompt, convert_func, text_color=None, bg_color=None, mode=0):
|
|
212
|
+
return _safe_try_except(prompt, False, convert_func, text_color, bg_color, mode)
|
|
213
|
+
|
|
214
|
+
def safe_int(prompt: str, text_color: Optional[int] = None, bg_color: Optional[int] = None, mode: int = 0) -> int:
|
|
215
|
+
""" 安全输出整数 """
|
|
216
|
+
return _safe_number(prompt, int, text_color, bg_color, mode)
|
|
217
|
+
|
|
218
|
+
def safe_float(prompt: str, text_color: Optional[int] = None, bg_color: Optional[int] = None, mode: int = 0) -> float:
|
|
219
|
+
""" 安全输出浮点数 """
|
|
220
|
+
return _safe_number(prompt, float, text_color, bg_color, mode)
|
|
221
|
+
|
|
222
|
+
# -- 测试部分 -- #
|
|
223
|
+
if __name__ == "__main__":
|
|
224
|
+
print("=== 测试基本颜色 ===\n=== Test basic colors ===")
|
|
225
|
+
color("红色文本\nRed text", text_color=31)
|
|
226
|
+
color("绿色加粗\nGreen bold", text_color=32, mode=1)
|
|
227
|
+
color("黄字红底\nYellow text Red background", text_color=33, bg_color=41)
|
|
228
|
+
color("红字黄底加粗\nRed text Yellow background Bold", text_color=31, bg_color=43, mode=1)
|
|
229
|
+
|
|
230
|
+
print("\n=== 测试RGB颜色 ===\n=== Test RGB colors ===")
|
|
231
|
+
color_rgb("RGB红色\nRGB Red", r=255, g=0, b=0)
|
|
232
|
+
color_rgb("RGB绿色加粗\nRGB Green Bold", r=0, g=255, b=0, mode=1)
|
|
233
|
+
|
|
234
|
+
print("\n=== 测试清屏 ===\n=== Test Clear Screen ===")
|
|
235
|
+
safe_input("按回车清屏...\nPress Enter to clear screen", 32, None, 1)
|
|
236
|
+
clear_screen()
|
|
237
|
+
color("清屏成功\nScreen cleared successfully", text_color=32, mode=1)
|
|
238
|
+
|
|
239
|
+
print('\n=== 测试"输入"函数 ===\n=== Test "Input" Functions ===')
|
|
240
|
+
name = safe_input("请输入名字(Please Enter Name): ", text_color=36)
|
|
241
|
+
age = safe_int("请输入年龄(Please Enter Age): ", text_color=33)
|
|
242
|
+
height = safe_float("请输入身高(米) (Please Enter height (m)): ", text_color=34)
|
|
243
|
+
|
|
244
|
+
color(f"\n你好 {name}, 年龄 {age}, 身高 {height}m\nHello {name}, Age {age}, height {height}", text_color=32, mode=1)
|
|
245
|
+
|
|
250
246
|
print("\n所有测试完成!\nAll Tests successfully!")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Luci-Code-Tools
|
|
3
|
-
Version: 2.1.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 2.1.4
|
|
4
|
+
Summary: 一个简单的工具库 / A Eazy Tools Module
|
|
5
5
|
Home-page: https://github.com/Luci-Codeing/code_tools
|
|
6
6
|
Author: Luci_Code
|
|
7
7
|
Author-email: 3967742419@qq.com
|
|
@@ -20,7 +20,7 @@ Dynamic: license-file
|
|
|
20
20
|
Dynamic: requires-python
|
|
21
21
|
Dynamic: summary
|
|
22
22
|
|
|
23
|
-
[](https://pypi.org/project/Luci_Code_Tools/)
|
|
24
24
|
|
|
25
25
|
[]()
|
|
26
26
|
|
|
@@ -118,8 +118,8 @@ MIT Licence (c) Luci_Code
|
|
|
118
118
|
|
|
119
119
|
| 函数名 | 功能 | 参数列表 |
|
|
120
120
|
| --- | --- | --- |
|
|
121
|
-
| color_rgb | 输出真彩色文本, 支持 rgb 调色 | data, r, g, b,
|
|
122
|
-
| color | 输出 ANSI 转义序列固定颜色, 适合不会调色的开发者 | data, text_color, bg_color, mode,
|
|
121
|
+
| color_rgb | 输出真彩色文本, 支持 rgb 调色 | data, r, g, b, line |
|
|
122
|
+
| color | 输出 ANSI 转义序列固定颜色, 适合不会调色的开发者 | data, text_color, bg_color, mode, line |
|
|
123
123
|
| clear_screen | 在任意系统下都能清屏的函数 | 无参数 |
|
|
124
124
|
| safe_input | 让用户安全的输入字符串 | prompt, text_color, bg_color, mode |
|
|
125
125
|
| safe_int | 让用户安全的输入整数 | prompt, text_color, bg_color, mode |
|
|
@@ -129,27 +129,32 @@ MIT Licence (c) Luci_Code
|
|
|
129
129
|
|
|
130
130
|
# 参数使用教程
|
|
131
131
|
|
|
132
|
-
**
|
|
132
|
+
**line** 是指在原本的基础上再输出 ** {num} ** 行, 默认为 2 (多一行)
|
|
133
133
|
|
|
134
134
|
***输出效果:***
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
line = 1 : [
|
|
137
|
+
content1
|
|
138
|
+
content2
|
|
139
|
+
input: Luci
|
|
140
|
+
]
|
|
137
141
|
|
|
138
|
-
|
|
139
|
-
|
|
142
|
+
line = 2 : [
|
|
143
|
+
content1 (line = 1)
|
|
144
|
+
content2
|
|
140
145
|
|
|
141
|
-
input:
|
|
146
|
+
input: Luci
|
|
147
|
+
]
|
|
142
148
|
|
|
143
|
-
|
|
149
|
+
line = 3 : [
|
|
150
|
+
content1 (line = 1)
|
|
151
|
+
content2
|
|
144
152
|
|
|
145
|
-
- newline=False :
|
|
146
153
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
input: content
|
|
150
|
-
if-content-prompt
|
|
154
|
+
input: Luci
|
|
155
|
+
]
|
|
151
156
|
|
|
152
|
-
|
|
157
|
+
**这一改动让命令行的输出变得有辨识度**
|
|
153
158
|
|
|
154
159
|
**data, prompt** 都是 *输出的文本* 的意思
|
|
155
160
|
|
|
@@ -157,13 +162,13 @@ if-content-prompt
|
|
|
157
162
|
|
|
158
163
|
- **color_rgb**
|
|
159
164
|
|
|
160
|
-
**color_rgb** 的参数有: data, r, g, b,
|
|
165
|
+
**color_rgb** 的参数有: data, r, g, b, line
|
|
161
166
|
|
|
162
|
-
**其中**, data 是数据的意思, 代表输出的内容, [r, g, b] 是 ***标准 rgb 调色*** 的用处, 所以 [r, g, b] 分别填入 r, g, b 的值,
|
|
167
|
+
**其中**, data 是数据的意思, 代表输出的内容, [r, g, b] 是 ***标准 rgb 调色*** 的用处, 所以 [r, g, b] 分别填入 r, g, b 的值, line 不用讲解, 前面说了喵
|
|
163
168
|
|
|
164
169
|
- **color**
|
|
165
170
|
|
|
166
|
-
**color** 的参数有: data, text_color, bg_color, mode,
|
|
171
|
+
**color** 的参数有: data, text_color, bg_color, mode, line
|
|
167
172
|
|
|
168
173
|
**data** 和之前一样, ***[text_color, bg_color, mode]***, 这三个参数在 safe_\* 中也有, 意思相同, 暂不讲解, **text_color** 就是控制输出的文本的颜色**(前景色)**, bg_color** 是输出文本的**背景色**, **mode** 为输出的格式 **(显示方式)**, 这三个参数在最后会有**表格对照表**
|
|
169
174
|
|
|
@@ -259,6 +264,7 @@ if-content-prompt
|
|
|
259
264
|
# 制作者 & 感谢名单
|
|
260
265
|
|
|
261
266
|
| 制作 | 分工 |
|
|
267
|
+
| --- | --- |
|
|
262
268
|
| DeepSeek | 检查 |
|
|
263
269
|
| DeepSeek | 改进方法 |
|
|
264
270
|
| Luci_Code | 改进 |
|
|
@@ -371,8 +377,8 @@ MIT License (c) Luci_Code
|
|
|
371
377
|
|
|
372
378
|
| Function Name | Functionality | Parameter List |
|
|
373
379
|
| --- | --- | --- |
|
|
374
|
-
| color_rgb | Outputs true-color text; supports RGB color customization. | data, r, g, b,
|
|
375
|
-
| color | Outputs text using fixed ANSI escape sequence colors; suitable for developers unfamiliar with color mixing. | data, text_color, bg_color, mode,
|
|
380
|
+
| color_rgb | Outputs true-color text; supports RGB color customization. | data, r, g, b, line |
|
|
381
|
+
| color | Outputs text using fixed ANSI escape sequence colors; suitable for developers unfamiliar with color mixing. | data, text_color, bg_color, mode, line |
|
|
376
382
|
| clear_screen | A function that clears the screen on any operating system. | No parameters |
|
|
377
383
|
| safe_input | Safely prompts the user to input a string. | prompt, text_color, bg_color, mode |
|
|
378
384
|
| safe_int | Safely prompts the user to input an integer. | prompt, text_color, bg_color, mode |
|
|
@@ -382,11 +388,11 @@ MIT License (c) Luci_Code
|
|
|
382
388
|
|
|
383
389
|
# Parameter Usage Guide
|
|
384
390
|
|
|
385
|
-
**
|
|
391
|
+
**line** refers to whether an additional line break is added after the output; it defaults to `True` (adding an extra line).
|
|
386
392
|
|
|
387
393
|
***Output Effect:***
|
|
388
394
|
|
|
389
|
-
- `
|
|
395
|
+
- `line=True`:
|
|
390
396
|
|
|
391
397
|
content-1 (Here, this implies `False`)
|
|
392
398
|
content-2
|
|
@@ -395,7 +401,7 @@ input: content
|
|
|
395
401
|
|
|
396
402
|
if-content-prompt
|
|
397
403
|
|
|
398
|
-
- `
|
|
404
|
+
- `line=False`:
|
|
399
405
|
|
|
400
406
|
content-1
|
|
401
407
|
content-2
|
|
@@ -410,13 +416,13 @@ if-content-prompt
|
|
|
410
416
|
|
|
411
417
|
- **color_rgb**
|
|
412
418
|
|
|
413
|
-
The parameters for **color_rgb** are: data, r, g, b,
|
|
419
|
+
The parameters for **color_rgb** are: data, r, g, b, line.
|
|
414
420
|
|
|
415
|
-
**Specifically:** `data` refers to the actual content being output; `[r, g, b]` are used for ***standard RGB color mixing***—simply fill in the respective values for r, g, and b. The `
|
|
421
|
+
**Specifically:** `data` refers to the actual content being output; `[r, g, b]` are used for ***standard RGB color mixing***—simply fill in the respective values for r, g, and b. The `line` parameter requires no further explanation, as it was covered earlier!
|
|
416
422
|
|
|
417
423
|
- **color**
|
|
418
424
|
|
|
419
|
-
The parameters for **color** are: `data`, `text_color`, `bg_color`, `mode`, and `
|
|
425
|
+
The parameters for **color** are: `data`, `text_color`, `bg_color`, `mode`, and `line`.
|
|
420
426
|
|
|
421
427
|
**data**: As before, this takes the format `[text_color, bg_color, mode]`. These three parameters also appear in the `safe_*` functions with the same meanings, so we won't explain them again here. **text_color** controls the color of the output text (the **foreground color**); **bg_color** controls the **background color** of the output text; and **mode** specifies the output format (the **display style**). A **reference table** for these three parameters can be found at the end of this document.
|
|
422
428
|
|
|
@@ -512,6 +518,7 @@ The explanations for these two functions are essentially identical to that of **
|
|
|
512
518
|
# Credits & Acknowledgments
|
|
513
519
|
|
|
514
520
|
| Contributor | Role |
|
|
521
|
+
| --- | --- |
|
|
515
522
|
| DeepSeek | Review |
|
|
516
523
|
| DeepSeek | Method Improvement |
|
|
517
524
|
| Luci_Code | Improvements |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[](https://pypi.org/project/Luci_Code_Tools/)
|
|
2
2
|
|
|
3
3
|
[]()
|
|
4
4
|
|
|
@@ -96,8 +96,8 @@ MIT Licence (c) Luci_Code
|
|
|
96
96
|
|
|
97
97
|
| 函数名 | 功能 | 参数列表 |
|
|
98
98
|
| --- | --- | --- |
|
|
99
|
-
| color_rgb | 输出真彩色文本, 支持 rgb 调色 | data, r, g, b,
|
|
100
|
-
| color | 输出 ANSI 转义序列固定颜色, 适合不会调色的开发者 | data, text_color, bg_color, mode,
|
|
99
|
+
| color_rgb | 输出真彩色文本, 支持 rgb 调色 | data, r, g, b, line |
|
|
100
|
+
| color | 输出 ANSI 转义序列固定颜色, 适合不会调色的开发者 | data, text_color, bg_color, mode, line |
|
|
101
101
|
| clear_screen | 在任意系统下都能清屏的函数 | 无参数 |
|
|
102
102
|
| safe_input | 让用户安全的输入字符串 | prompt, text_color, bg_color, mode |
|
|
103
103
|
| safe_int | 让用户安全的输入整数 | prompt, text_color, bg_color, mode |
|
|
@@ -107,27 +107,32 @@ MIT Licence (c) Luci_Code
|
|
|
107
107
|
|
|
108
108
|
# 参数使用教程
|
|
109
109
|
|
|
110
|
-
**
|
|
110
|
+
**line** 是指在原本的基础上再输出 ** {num} ** 行, 默认为 2 (多一行)
|
|
111
111
|
|
|
112
112
|
***输出效果:***
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
line = 1 : [
|
|
115
|
+
content1
|
|
116
|
+
content2
|
|
117
|
+
input: Luci
|
|
118
|
+
]
|
|
115
119
|
|
|
116
|
-
|
|
117
|
-
|
|
120
|
+
line = 2 : [
|
|
121
|
+
content1 (line = 1)
|
|
122
|
+
content2
|
|
118
123
|
|
|
119
|
-
input:
|
|
124
|
+
input: Luci
|
|
125
|
+
]
|
|
120
126
|
|
|
121
|
-
|
|
127
|
+
line = 3 : [
|
|
128
|
+
content1 (line = 1)
|
|
129
|
+
content2
|
|
122
130
|
|
|
123
|
-
- newline=False :
|
|
124
131
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
input: content
|
|
128
|
-
if-content-prompt
|
|
132
|
+
input: Luci
|
|
133
|
+
]
|
|
129
134
|
|
|
130
|
-
|
|
135
|
+
**这一改动让命令行的输出变得有辨识度**
|
|
131
136
|
|
|
132
137
|
**data, prompt** 都是 *输出的文本* 的意思
|
|
133
138
|
|
|
@@ -135,13 +140,13 @@ if-content-prompt
|
|
|
135
140
|
|
|
136
141
|
- **color_rgb**
|
|
137
142
|
|
|
138
|
-
**color_rgb** 的参数有: data, r, g, b,
|
|
143
|
+
**color_rgb** 的参数有: data, r, g, b, line
|
|
139
144
|
|
|
140
|
-
**其中**, data 是数据的意思, 代表输出的内容, [r, g, b] 是 ***标准 rgb 调色*** 的用处, 所以 [r, g, b] 分别填入 r, g, b 的值,
|
|
145
|
+
**其中**, data 是数据的意思, 代表输出的内容, [r, g, b] 是 ***标准 rgb 调色*** 的用处, 所以 [r, g, b] 分别填入 r, g, b 的值, line 不用讲解, 前面说了喵
|
|
141
146
|
|
|
142
147
|
- **color**
|
|
143
148
|
|
|
144
|
-
**color** 的参数有: data, text_color, bg_color, mode,
|
|
149
|
+
**color** 的参数有: data, text_color, bg_color, mode, line
|
|
145
150
|
|
|
146
151
|
**data** 和之前一样, ***[text_color, bg_color, mode]***, 这三个参数在 safe_\* 中也有, 意思相同, 暂不讲解, **text_color** 就是控制输出的文本的颜色**(前景色)**, bg_color** 是输出文本的**背景色**, **mode** 为输出的格式 **(显示方式)**, 这三个参数在最后会有**表格对照表**
|
|
147
152
|
|
|
@@ -237,6 +242,7 @@ if-content-prompt
|
|
|
237
242
|
# 制作者 & 感谢名单
|
|
238
243
|
|
|
239
244
|
| 制作 | 分工 |
|
|
245
|
+
| --- | --- |
|
|
240
246
|
| DeepSeek | 检查 |
|
|
241
247
|
| DeepSeek | 改进方法 |
|
|
242
248
|
| Luci_Code | 改进 |
|
|
@@ -349,8 +355,8 @@ MIT License (c) Luci_Code
|
|
|
349
355
|
|
|
350
356
|
| Function Name | Functionality | Parameter List |
|
|
351
357
|
| --- | --- | --- |
|
|
352
|
-
| color_rgb | Outputs true-color text; supports RGB color customization. | data, r, g, b,
|
|
353
|
-
| color | Outputs text using fixed ANSI escape sequence colors; suitable for developers unfamiliar with color mixing. | data, text_color, bg_color, mode,
|
|
358
|
+
| color_rgb | Outputs true-color text; supports RGB color customization. | data, r, g, b, line |
|
|
359
|
+
| color | Outputs text using fixed ANSI escape sequence colors; suitable for developers unfamiliar with color mixing. | data, text_color, bg_color, mode, line |
|
|
354
360
|
| clear_screen | A function that clears the screen on any operating system. | No parameters |
|
|
355
361
|
| safe_input | Safely prompts the user to input a string. | prompt, text_color, bg_color, mode |
|
|
356
362
|
| safe_int | Safely prompts the user to input an integer. | prompt, text_color, bg_color, mode |
|
|
@@ -360,11 +366,11 @@ MIT License (c) Luci_Code
|
|
|
360
366
|
|
|
361
367
|
# Parameter Usage Guide
|
|
362
368
|
|
|
363
|
-
**
|
|
369
|
+
**line** refers to whether an additional line break is added after the output; it defaults to `True` (adding an extra line).
|
|
364
370
|
|
|
365
371
|
***Output Effect:***
|
|
366
372
|
|
|
367
|
-
- `
|
|
373
|
+
- `line=True`:
|
|
368
374
|
|
|
369
375
|
content-1 (Here, this implies `False`)
|
|
370
376
|
content-2
|
|
@@ -373,7 +379,7 @@ input: content
|
|
|
373
379
|
|
|
374
380
|
if-content-prompt
|
|
375
381
|
|
|
376
|
-
- `
|
|
382
|
+
- `line=False`:
|
|
377
383
|
|
|
378
384
|
content-1
|
|
379
385
|
content-2
|
|
@@ -388,13 +394,13 @@ if-content-prompt
|
|
|
388
394
|
|
|
389
395
|
- **color_rgb**
|
|
390
396
|
|
|
391
|
-
The parameters for **color_rgb** are: data, r, g, b,
|
|
397
|
+
The parameters for **color_rgb** are: data, r, g, b, line.
|
|
392
398
|
|
|
393
|
-
**Specifically:** `data` refers to the actual content being output; `[r, g, b]` are used for ***standard RGB color mixing***—simply fill in the respective values for r, g, and b. The `
|
|
399
|
+
**Specifically:** `data` refers to the actual content being output; `[r, g, b]` are used for ***standard RGB color mixing***—simply fill in the respective values for r, g, and b. The `line` parameter requires no further explanation, as it was covered earlier!
|
|
394
400
|
|
|
395
401
|
- **color**
|
|
396
402
|
|
|
397
|
-
The parameters for **color** are: `data`, `text_color`, `bg_color`, `mode`, and `
|
|
403
|
+
The parameters for **color** are: `data`, `text_color`, `bg_color`, `mode`, and `line`.
|
|
398
404
|
|
|
399
405
|
**data**: As before, this takes the format `[text_color, bg_color, mode]`. These three parameters also appear in the `safe_*` functions with the same meanings, so we won't explain them again here. **text_color** controls the color of the output text (the **foreground color**); **bg_color** controls the **background color** of the output text; and **mode** specifies the output format (the **display style**). A **reference table** for these three parameters can be found at the end of this document.
|
|
400
406
|
|
|
@@ -490,6 +496,7 @@ The explanations for these two functions are essentially identical to that of **
|
|
|
490
496
|
# Credits & Acknowledgments
|
|
491
497
|
|
|
492
498
|
| Contributor | Role |
|
|
499
|
+
| --- | --- |
|
|
493
500
|
| DeepSeek | Review |
|
|
494
501
|
| DeepSeek | Method Improvement |
|
|
495
502
|
| Luci_Code | Improvements |
|
|
@@ -5,10 +5,10 @@ with open("README.md", "r", encoding="utf-8") as f:
|
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name="Luci-Code-Tools",
|
|
8
|
-
version="2.1.
|
|
8
|
+
version="2.1.4",
|
|
9
9
|
author="Luci_Code",
|
|
10
10
|
author_email="3967742419@qq.com",
|
|
11
|
-
description="
|
|
11
|
+
description="一个简单的工具库 / A Eazy Tools Module",
|
|
12
12
|
long_description=long_description,
|
|
13
13
|
long_description_content_type="text/markdown",
|
|
14
14
|
url="https://github.com/Luci-Codeing/code_tools",
|
|
File without changes
|
|
File without changes
|
{luci_code_tools-2.1.2 → luci_code_tools-2.1.4}/Luci_Code_Tools.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|