Luci-Code-Tools 2.0.0__tar.gz → 2.1.3__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,531 @@
1
+ Metadata-Version: 2.4
2
+ Name: Luci-Code-Tools
3
+ Version: 2.1.3
4
+ Summary: 安全输入工具库,支持彩色输出,KeyboardInterrupt保护等
5
+ Home-page: https://github.com/Luci-Codeing/code_tools
6
+ Author: Luci_Code
7
+ Author-email: 3967742419@qq.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Requires-Python: >=3.6
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENCE
13
+ Dynamic: author
14
+ Dynamic: author-email
15
+ Dynamic: classifier
16
+ Dynamic: description
17
+ Dynamic: description-content-type
18
+ Dynamic: home-page
19
+ Dynamic: license-file
20
+ Dynamic: requires-python
21
+ Dynamic: summary
22
+
23
+ [![PyPI version](https://badge.fury.io/py/luci-code-tools.svg)](https://pypi.org/project/Luci_Code_Tools/)
24
+
25
+ [![Python Version](https://img.shields.io/badge/Python-3.6+-blue.svg)]()
26
+
27
+ [![License](https://img.shields.io/badge/License-MIT-green.svg)]()
28
+
29
+ [![Cat](https://img.shields.io/badge/Cat-Approved-orange.svg)]()
30
+
31
+ ---
32
+
33
+ **English document is located at the very bottom**
34
+
35
+ **This English document was translated using Google Translate and may contain inaccuracies**
36
+
37
+ ---
38
+
39
+ # 感谢
40
+
41
+ **你点开了这个 *README.md***
42
+
43
+ **非常感谢你点进来喵🐱**
44
+
45
+ **我叫 Luci_Code**
46
+
47
+ **是一名 2014 年出生的开发者**
48
+
49
+ **2025 年 11 月开始学习编程**
50
+
51
+ ---
52
+
53
+ # 现在开始功能介绍喵🐱
54
+
55
+ ## ✨ 特性
56
+
57
+ - 🎨 **ANSI 真彩色** + RGB 支持, 想要什么颜色就什么颜色
58
+ - 🛡️ **20+ 异常处理**
59
+ - 🌐 **中英双语**, 谁都能看懂错误信息
60
+ - 🐧 **跨平台**, 支持: Windows / macOS / Linux / Android
61
+ - 📝 **注释比代码还多**, 不怕看不懂
62
+ - 😼 **由一位 2014 出生年的作者维护**, 从 2025 年 11 月开始学
63
+
64
+ ## ⚙ 函数
65
+
66
+ - color
67
+ - color_rgb
68
+ - clear_screen
69
+ - safe_input
70
+ - safe_int
71
+ - safe_float
72
+
73
+ ## 🎞 安装 & 使用
74
+
75
+ **安装**
76
+
77
+ ```bash
78
+ pip install Luci-Code-Tools
79
+ ```
80
+
81
+ **使用**
82
+
83
+ - 方式 1 - import
84
+
85
+ ```python
86
+ import Luci_code_tools
87
+ Luci_code_tools.color("字符输出", 32, None, 1)
88
+ ```
89
+
90
+ - 方式 1 - 附加 as
91
+
92
+ ```python
93
+ import Luci_code_tools as lct
94
+ lct.color("字符输出", 32, None, 1)
95
+ ```
96
+
97
+ - 方式 2 - from
98
+
99
+ ```python
100
+ from Luci_code_tools import color
101
+ color("字符输出", 32, None, 1)
102
+ ```
103
+
104
+ - 方式 2 - from - 附加 as
105
+
106
+ ```python
107
+ from Luci_code_tools import color as cl
108
+ cl("字符输出", 32, None, 1)
109
+ ```
110
+
111
+ ## 📃 许可证
112
+
113
+ MIT Licence (c) Luci_Code
114
+
115
+ ---
116
+
117
+ # 🛠 函数
118
+
119
+ | 函数名 | 功能 | 参数列表 |
120
+ | --- | --- | --- |
121
+ | color_rgb | 输出真彩色文本, 支持 rgb 调色 | data, r, g, b, newline |
122
+ | color | 输出 ANSI 转义序列固定颜色, 适合不会调色的开发者 | data, text_color, bg_color, mode, newline |
123
+ | clear_screen | 在任意系统下都能清屏的函数 | 无参数 |
124
+ | safe_input | 让用户安全的输入字符串 | prompt, text_color, bg_color, mode |
125
+ | safe_int | 让用户安全的输入整数 | prompt, text_color, bg_color, mode |
126
+ | safe_float | 让用户安全的输入浮点数 | prompt, text_color, bg_color, mode |
127
+
128
+ ---
129
+
130
+ # 参数使用教程
131
+
132
+ **newline** 是指在原本的基础上再输出一行, 默认为 True (多一行)
133
+
134
+ ***输出效果:***
135
+
136
+ - newline=True :
137
+
138
+ content-1 (此处为 False)
139
+ content-2
140
+
141
+ input: content
142
+
143
+ if-content-prompt
144
+
145
+ - newline=False :
146
+
147
+ content-1
148
+ content-2
149
+ input: content
150
+ if-content-prompt
151
+
152
+ **这一改动让命令行的输出变得有辨识度, 高级**
153
+
154
+ **data, prompt** 都是 *输出的文本* 的意思
155
+
156
+ ---
157
+
158
+ - **color_rgb**
159
+
160
+ **color_rgb** 的参数有: data, r, g, b, newline
161
+
162
+ **其中**, data 是数据的意思, 代表输出的内容, [r, g, b] 是 ***标准 rgb 调色*** 的用处, 所以 [r, g, b] 分别填入 r, g, b 的值, newline 不用讲解, 前面说了喵
163
+
164
+ - **color**
165
+
166
+ **color** 的参数有: data, text_color, bg_color, mode, newline
167
+
168
+ **data** 和之前一样, ***[text_color, bg_color, mode]***, 这三个参数在 safe_\* 中也有, 意思相同, 暂不讲解, **text_color** 就是控制输出的文本的颜色**(前景色)**, bg_color** 是输出文本的**背景色**, **mode** 为输出的格式 **(显示方式)**, 这三个参数在最后会有**表格对照表**
169
+
170
+ - **clear_screen**
171
+
172
+ **clear_screen** 没有任何参数, 使用就清屏, 无论在 **Linux, MacOS, Windows, Android** 上都能运行, 我们还贴心的为 **REPL / 交互式环境和脚本** 和 **非交互式环境** 准备了不同的方案, 确保他们都能运行喵
173
+
174
+ - **safe_input**
175
+
176
+ **safe_input** 的参数有 ***[prompt, text_color, bg_color, mode]***
177
+
178
+ 这些似乎都不用讲解了, 毕竟参数全都讲解过了, [prompt] 在 (# 参数使用教程) 的下方, **text_color**, **bg_color, mode** 在 **color** 函数中讲解了
179
+
180
+ - **safe_int** / **safe_float**
181
+
182
+ 这两个函数和 **safe_input** 的函数讲解基本相同, 我就不重复了喵
183
+
184
+ **safe_int**, **safe_float** 分别是 **安全输入整数**, **安全输入浮点数**
185
+
186
+ ---
187
+
188
+ # 参数对照表
189
+
190
+ ## 前景色
191
+
192
+ | 前景色 - 值 | 效果 |
193
+ | --- | --- |
194
+ | 30 | 黑色 |
195
+ | 31 | 红色 |
196
+ | 32 | 绿色 |
197
+ | 33 | 黄色 |
198
+ | 34 | 蓝色 |
199
+ | 35 | 紫色 |
200
+ | 36 | 青色 |
201
+ | 37 | 白色 |
202
+
203
+ ## 前景色 - 浅色
204
+
205
+ | 前景色 - 值 | 效果 |
206
+ | --- | --- |
207
+ | 90 | 深灰色 |
208
+ | 91 | 浅红色 |
209
+ | 92 | 浅绿色 |
210
+ | 93 | 浅黄色 |
211
+ | 94 | 浅蓝色 |
212
+ | 95 | 浅紫色 |
213
+ | 96 | 浅青色 |
214
+ | 97 | 浅灰色 |
215
+
216
+ ## 背景色
217
+
218
+ | 背景色 - 值 | 效果 |
219
+ | --- | --- |
220
+ | 40 | 黑色 |
221
+ | 41 | 红色 |
222
+ | 42 | 绿色 |
223
+ | 43 | 黄色 |
224
+ | 44 | 蓝色 |
225
+ | 45 | 紫色 |
226
+ | 46 | 青色 |
227
+ | 47 | 白色 |
228
+
229
+ ## 背景色 - 浅色
230
+
231
+ | 背景色 - 值 | 效果 |
232
+ | --- | --- |
233
+ | 100 | 深灰色 |
234
+ | 101 | 浅红色 |
235
+ | 102 | 浅绿色 |
236
+ | 103 | 浅黄色 |
237
+ | 104 | 浅蓝色 |
238
+ | 105 | 浅紫色 |
239
+ | 106 | 浅青色 |
240
+ | 107 | 纯白色 |
241
+
242
+ ## 显示方式
243
+
244
+ | 显示方式 - 值 | 效果 |
245
+ | --- | --- |
246
+ | 0 | 默认 |
247
+ | 1 | 高亮 + 加粗 |
248
+ | 2 | 暗淡 |
249
+ | 3 | 斜体 (部分终端可能不支持) |
250
+ | 4 | 下划线 |
251
+ | 5 | 闪烁 |
252
+ | 6 | 快闪(部分终端可能不支持) |
253
+ | 7 | 反色(前景色与背景色互换) |
254
+ | 8 | 隐藏 |
255
+ | 9 | 删除线 |
256
+
257
+ ---
258
+
259
+ # 制作者 & 感谢名单
260
+
261
+ | 制作 | 分工 |
262
+ | --- | --- |
263
+ | DeepSeek | 检查 |
264
+ | DeepSeek | 改进方法 |
265
+ | Luci_Code | 改进 |
266
+ | Luci_Code | 思路 |
267
+ | Luci_Code | 文档 |
268
+ | Luci_Code | 上传 |
269
+ | Luci_Code | 制作初版 |
270
+
271
+ ---
272
+
273
+ # 感谢
274
+
275
+ **< 感谢你看到这里 >**
276
+
277
+ **一位 2014 年出生的开发者**
278
+
279
+ ---
280
+
281
+ # English document
282
+
283
+ [![PyPI version](https://badge.fury.io/py/luci-code-tools.svg)](https://pypi.org/project/luci-code-tools/)
284
+
285
+ [![Python Version](https://img.shields.io/badge/Python-3.6+-blue.svg)]()
286
+
287
+ [![License](https://img.shields.io/badge/License-MIT-green.svg)]()
288
+
289
+ [![Cat](https://img.shields.io/badge/Cat-Approved-orange.svg)]()
290
+
291
+ ---
292
+
293
+ # Thank You
294
+
295
+ **for clicking on this README.md**
296
+
297
+ **Thank you so much for stopping by! 🐱**
298
+
299
+ **My name is Luci_Code**
300
+
301
+ **I am a developer born in 2014**
302
+
303
+ **I started learning to program in November 2025**
304
+
305
+ ---
306
+
307
+ # Now, let's introduce the features! 🐱
308
+
309
+ ## ✨ Features
310
+
311
+ - 🎨 **ANSI True Color** + RGB support—pick any color you desire!
312
+ - 🛡️ **20+ Exception Handlers**
313
+ - 🌐 **Bilingual Support (Chinese/English)**—everyone can understand the error messages
314
+ - 🐧 **Cross-Platform**—supports: Windows / macOS / Linux / Android
315
+ - 📝 **More Comments Than Code**—no need to worry about not understanding it
316
+ - 😼 **Maintained by an Author Born in 2014**—who started learning in November 2025
317
+
318
+ ## ⚙ Functions
319
+
320
+ - color
321
+ - color_rgb
322
+ - clear_screen
323
+ - safe_input
324
+ - safe_int
325
+ - safe_float
326
+
327
+ ## 🎞 Installation & Usage
328
+
329
+ **Installation**
330
+
331
+ ```bash
332
+ pip install Luci-Code-Tools
333
+ ```
334
+
335
+ **Usage**
336
+
337
+ - Method 1 - `import`
338
+
339
+ ```python
340
+ import Luci_code_tools
341
+ Luci_code_tools.color("Text Output", 32, None, 1)
342
+ ```
343
+
344
+ - Method 1 - `import ... as ...`
345
+
346
+ ```python
347
+ import Luci_code_tools as lct
348
+ lct.color("Text Output", 32, None, 1)
349
+ ```
350
+
351
+ - Method 2 - `from ... import ...`
352
+
353
+ ```python
354
+ from Luci_code_tools import color
355
+ color("Character Output", 32, None, 1)
356
+ ```
357
+
358
+ - Method 2 - `from` - with `as` alias
359
+
360
+ ```python
361
+ from Luci_code_tools import color as cl
362
+ cl("Character Output", 32, None, 1)
363
+ ```
364
+
365
+ ## 📃 License
366
+
367
+ MIT License (c) Luci_Code
368
+
369
+ ---
370
+
371
+ # 🛠 Functions
372
+
373
+ | Function Name | Functionality | Parameter List |
374
+ | --- | --- | --- |
375
+ | color_rgb | Outputs true-color text; supports RGB color customization. | data, r, g, b, newline |
376
+ | color | Outputs text using fixed ANSI escape sequence colors; suitable for developers unfamiliar with color mixing. | data, text_color, bg_color, mode, newline |
377
+ | clear_screen | A function that clears the screen on any operating system. | No parameters |
378
+ | safe_input | Safely prompts the user to input a string. | prompt, text_color, bg_color, mode |
379
+ | safe_int | Safely prompts the user to input an integer. | prompt, text_color, bg_color, mode |
380
+ | safe_float | Safely prompts the user to input a floating-point number. | prompt, text_color, bg_color, mode |
381
+
382
+ ---
383
+
384
+ # Parameter Usage Guide
385
+
386
+ **newline** refers to whether an additional line break is added after the output; it defaults to `True` (adding an extra line).
387
+
388
+ ***Output Effect:***
389
+
390
+ - `newline=True`:
391
+
392
+ content-1 (Here, this implies `False`)
393
+ content-2
394
+
395
+ input: content
396
+
397
+ if-content-prompt
398
+
399
+ - `newline=False`:
400
+
401
+ content-1
402
+ content-2
403
+ input: content
404
+ if-content-prompt
405
+
406
+ **This modification makes the command-line output more visually distinct and sophisticated.**
407
+
408
+ **data** and **prompt** both refer to the *text being output*.
409
+
410
+ ---
411
+
412
+ - ​​**color_rgb**
413
+
414
+ The parameters for **color_rgb** are: data, r, g, b, newline.
415
+
416
+ **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 `newline` parameter requires no further explanation, as it was covered earlier!
417
+
418
+ - **color**
419
+
420
+ The parameters for **color** are: `data`, `text_color`, `bg_color`, `mode`, and `newline`.
421
+
422
+ **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.
423
+
424
+ - **clear_screen**
425
+
426
+ **clear_screen** takes no arguments; simply calling it clears the screen. It works across **Linux, MacOS, Windows, and Android**. We have also thoughtfully implemented different solutions for **REPL/interactive environments (and scripts)** versus **non-interactive environments** to ensure it functions correctly in all scenarios.
427
+
428
+ - **safe_input**
429
+
430
+ The parameters for **safe_input** are: `[prompt, text_color, bg_color, mode]`.
431
+
432
+ These likely require no further explanation, as all the parameters have already been covered. The `[prompt]` parameter is discussed below in the (# Parameter Usage Tutorial) section, while **text_color**, **bg_color**, and **mode** were explained in the **color** function section.
433
+
434
+ - **safe_int** / **safe_float**
435
+
436
+ The explanations for these two functions are essentially identical to that of **safe_input**, so I won't repeat myself here.
437
+
438
+ **safe_int** and **safe_float** are used for **safely inputting integers** and **safely inputting floating-point numbers**, respectively.
439
+
440
+ ---
441
+
442
+ # Parameter Reference Table
443
+
444
+ ## Foreground Colors
445
+
446
+ | Foreground Value | Effect |
447
+ | --- | --- |
448
+ | 30 | Black |
449
+ | 31 | Red |
450
+ | 32 | Green |
451
+ | 33 | Yellow |
452
+ | 34 | Blue |
453
+ | 35 | Purple |
454
+ | 36 | Cyan |
455
+ | 37 | White |
456
+
457
+ ## Foreground Colors - Light Tones
458
+
459
+ | Foreground Value | Effect |
460
+ | --- | --- |
461
+ | 90 | Dark Gray |
462
+ | 91 | Light Red |
463
+ | 92 | Light Green |
464
+ | 93 | Light Yellow |
465
+ | 94 | Light Blue |
466
+ | 95 | Light Purple |
467
+ | 96 | Light Cyan |
468
+ | 97 | Light Gray |
469
+
470
+ ## Background Colors
471
+
472
+ | Background Color - Value | Effect |
473
+ | --- | --- |
474
+ | 40 | Black |
475
+ | 41 | Red |
476
+ | 42 | Green |
477
+ | 43 | Yellow |
478
+ | 44 | Blue |
479
+ | 45 | Purple |
480
+ | 46 | Cyan |
481
+ | 47 | White |
482
+
483
+ ## Background Colors - Light Tones
484
+
485
+ | Background Color - Value | Effect |
486
+ | --- | --- |
487
+ | 100 | Dark Gray |
488
+ | 101 | Light Red |
489
+ | 102 | Light Green |
490
+ | 103 | Light Yellow |
491
+ | 104 | Light Blue |
492
+ | 105 | Light Purple |
493
+ | 106 | Light Cyan |
494
+ | 107 | Pure White |
495
+
496
+ ## Display Modes
497
+
498
+ | Display Mode - Value | Effect |
499
+ | --- | --- |
500
+ | 0 | Default |
501
+ | 1 | Highlight + Bold |
502
+ | 2 | Dim |
503
+ | 3 | Italic (May not be supported by some terminals) |
504
+ | 4 | Underline |
505
+ | 5 | Blink |
506
+ | 6 | Rapid Blink (May not be supported by some terminals) |
507
+ | 7 | Reverse (Foreground and background colors swapped) |
508
+ | 8 | Hidden |
509
+ | 9 | Strikethrough |
510
+
511
+ ---
512
+
513
+ # Credits & Acknowledgments
514
+
515
+ | Contributor | Role |
516
+ | --- | --- |
517
+ | DeepSeek | Review |
518
+ | DeepSeek | Method Improvement |
519
+ | Luci_Code | Improvements |
520
+ | Luci_Code | Conceptualization |
521
+ | Luci_Code | Documentation |
522
+ | Luci_Code | Upload |
523
+ | Luci_Code | First Edition |
524
+
525
+ ---
526
+
527
+ # Acknowledgments
528
+
529
+ **< Thank you for reading this far >**
530
+
531
+ **A developer born in 2014**