Luci-Code-Tools 2.3.0__tar.gz → 2.3.1__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 @@
1
+ MIT License
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Luci-Code-Tools
3
- Version: 2.3.0
3
+ Version: 2.3.1
4
4
  Summary: 一个简单的工具库 / A Eazy Tools Module
5
5
  Home-page: https://github.com/Luci-Code-2014
6
6
  Author: Luci_Code
@@ -10,7 +10,7 @@ if platform == "win32": # 判断平台
10
10
  except Exception:
11
11
  pass # os.system 会报错 😭 (比如 Python 的 exe 可执行程序没有命令也就是不能执行命令,即使命令为空以及嵌入式环境压根没有 Shell 😭)
12
12
 
13
- __version__ = "2.3.0" # 明确版本号
13
+ __version__ = "2.3.1" # 明确版本号
14
14
  __all__ = [
15
15
  'color', 'color_rgb', 'clear_screen',
16
16
  'safe_input', 'safe_int', 'safe_float'
@@ -116,7 +116,7 @@ def clear_screen() -> None: # 清屏 😭
116
116
  except: # 为了防止用户让终端的长度无法获取
117
117
  print("\n" * 250) # 防止获取不到终端长度的输出
118
118
 
119
- 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 模式 😭
119
+ def _safe_try_except(prompt, input_type=True, convert_func=None, text_color=None, bg_color=None, mode=0) -> Union[str, int, float]:
120
120
  if text_color is not None or bg_color is not None:
121
121
  prompt = _ansi_return(prompt, text_color, bg_color, mode)
122
122
  while True:
@@ -125,89 +125,115 @@ def _safe_try_except(prompt, input_type=True, convert_func=None, text_color=None
125
125
  return input(prompt)
126
126
  else:
127
127
  return convert_func(input(prompt))
128
- except MemoryError:
129
- if platform == "win32":
130
- error_code = "0x0000005E" # 😭
131
- else:
132
- error_code = "0xffffffffffffffff" # 😭
133
- color(f"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 {error_code})\n\n内存不足!\n\n内存不足,无法完成操作。\n\n请尝试:\n\n· 关闭其他应用后重试\n· 增加内存或交换空间\n· 如果问题仍然存在,请重启系 统\n操作已终止 (错误代码 {error_code})", 37, 44, 1)
134
- exit(1)
135
- except ValueError:
136
- color("Invalid input value type\n无效的输入值类型", 33, None, 1)
137
- continue
128
+
138
129
  except KeyboardInterrupt:
139
130
  clear_screen()
140
131
  color("Program interrupted\n程序被中断", 33, None, 1)
141
132
  exit(0)
133
+
142
134
  except EOFError:
143
135
  clear_screen()
144
136
  color("Input stream terminated\n输入流已终止", 33, None, 1)
145
137
  exit(0)
146
- except TimeoutError:
147
- color("Input timeout\n输入超时", 33, None, 1)
148
- exit(0)
138
+
149
139
  except UnicodeDecodeError:
150
140
  color("Unicode encoding error\nUnicode 编码错误", 33, None, 1)
151
141
  continue
152
- except OSError:
153
- color("OSError: System operation failed. Please check file path, permissions, or disk space.\nOSError:系统操作失败。请检查文件路径、权限或磁盘空间。", 37, 44, 1)
154
- exit(1)
142
+
143
+ except ValueError:
144
+ color("Invalid input value type\n无效的输入值类型", 33, None, 1)
145
+ continue
146
+
155
147
  except OverflowError:
156
148
  color("Value overflow\n数值溢出", 33, None, 1)
157
149
  continue
150
+
158
151
  except TypeError:
159
152
  color("Type conversion failed\n类型转换失败", 33, None, 1)
160
153
  continue
161
- except RuntimeError as e:
162
- color(f"Serious runtime error\nError message:\n{e}\n严重的运行时错误\n错误信息,\n{e}", 33, None, 1)
163
- exit(1)
164
- except SystemError:
165
- color("System error, please check Python interpreter\n系统错误,请检查 Python 解释器", 33, None, 1)
166
- exit(0)
167
- except AttributeError:
168
- color("Object has no such attribute\n对象没有此属性", 33, None, 1)
169
- continue
170
- except NameError:
171
- color("Variable or function not defined\n变量或函数未定义", 33, None, 1)
172
- exit(1)
173
- except SyntaxError:
174
- color("Syntax error in code\n代码中的语法错误", 33, None, 1)
175
- continue
154
+
176
155
  except RecursionError:
177
156
  color("Recursion depth exceeded\n超出递归深度", 33, None, 1)
178
157
  exit(1)
179
- except BrokenPipeError:
180
- color("Input pipe closed by other end\n输入管道被另一端关闭", 33, None, 1)
158
+
159
+ except RuntimeError as e:
160
+ color(f"Serious runtime error\nError message:\n{e}\n严重的运行时错误\n错误信息,\n{e}", 33, None, 1)
181
161
  exit(1)
182
- except ConnectionError:
183
- color("Input from network stream and connection lost\n来自网络流的输入,连接已丢失", 33, None, 1)
162
+
163
+ except MemoryError:
164
+ if platform == "win32":
165
+ error_code = "0x0000005E"
166
+ else:
167
+ error_code = "0xffffffffffffffff"
168
+ color(f"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 {error_code})\n\n内存不足!\n\n内存不足,无法完成操作。\n\n请尝试:\n\n· 关闭其他应用后重试\n· 增加内存或交换空间\n· 如果问题仍然存在,请重启系 统\n操作已终止 (错误代码 {error_code})", 37, 44, 1)
184
169
  exit(1)
170
+
185
171
  except FileNotFoundError:
186
172
  color("Input source file not found\n未找到输入源 文件", 33, None, 1)
187
173
  exit(1)
174
+
188
175
  except IsADirectoryError:
189
176
  color("Input source is a directory, not a file\n 输入源是一个目录,而不是文件", 33, None, 1)
190
177
  exit(1)
178
+
191
179
  except PermissionError:
192
180
  color("Permission denied to read input source\n权限被拒绝,无法读取输入源", 33, None, 1)
193
181
  exit(1)
194
- except BlockingIOError:
195
- color("No data to read in non-blocking mode\n非阻塞模式下没有数据可读", 33, None, 1)
196
- continue
182
+
197
183
  except ChildProcessError:
198
184
  color("Child process operation failed\n子进程操作失败", 33, None, 1)
199
185
  exit(1)
186
+
187
+ except BrokenPipeError:
188
+ color("Input pipe closed by other end\n输入管道被另一端关闭", 33, None, 1)
189
+ exit(1)
190
+
191
+ except ConnectionError:
192
+ color("Input from network stream and connection lost\n来自网络流的输入,连接已丢失", 33, None, 1)
193
+ exit(1)
194
+
195
+ except TimeoutError:
196
+ color("Input timeout\n输入超时", 33, None, 1)
197
+ exit(0)
198
+
199
+ except BlockingIOError:
200
+ color("No data to read in non-blocking mode\n非阻塞模式下没有数据可读", 33, None, 1)
201
+ continue
202
+
200
203
  except InterruptedError:
201
204
  color("System call interrupted by signal\n系统调 用被信号中断", 33, None, 1)
202
205
  continue
206
+
207
+ except OSError:
208
+ color("OSError: System operation failed. Please check file path, permissions, or disk space.\nOSError:系统操作失败。请检查文件路径、权限或磁盘空间。", 37, 44, 1)
209
+ exit(1)
210
+
211
+ except SystemError:
212
+ color("System error, please check Python interpreter\n系统错误,请检查 Python 解释器", 33, None, 1)
213
+ exit(0)
214
+
215
+ except NameError:
216
+ color("Variable or function not defined\n变量或函数未定义", 33, None, 1)
217
+ exit(1)
218
+
219
+ except AttributeError:
220
+ color("Object has no such attribute\n对象没有此属性", 33, None, 1)
221
+ continue
222
+
223
+ except SyntaxError:
224
+ color("Syntax error in code\n代码中的语法错误", 33, None, 1)
225
+ continue
226
+
203
227
  except StopIteration:
204
228
  color("Custom iterator input exhausted\n自定义迭 代器输入已耗尽", 33, None, 1)
205
229
  continue
230
+
206
231
  except GeneratorExit:
207
232
  color("Generator closed\n生成器已关闭", 33, None, 1)
208
233
  continue
234
+
209
235
  except Exception as e:
210
- color(f"Code error\nError message:\n{e}\n代码错误\n错误信息:\n{e}", 33, None, 1) # 应该不会有人到这一步 😭
236
+ color(f"Code error\nError message:\n{e}\n代码错误\n错误信息:\n{e}", 33, None, 1)
211
237
  exit(1)
212
238
 
213
239
  def safe_input(prompt: str, text_color: Optional[int] = None, bg_color: Optional[int] = None, mode: int = 0) -> str: # 😭
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Luci-Code-Tools
3
- Version: 2.3.0
3
+ Version: 2.3.1
4
4
  Summary: 一个简单的工具库 / A Eazy Tools Module
5
5
  Home-page: https://github.com/Luci-Code-2014
6
6
  Author: Luci_Code
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as f:
5
5
 
6
6
  setup(
7
7
  name="Luci-Code-Tools",
8
- version="2.3.0",
8
+ version="2.3.1",
9
9
  author="Luci_Code",
10
10
  author_email="luci90031@gmail.com",
11
11
  description="一个简单的工具库 / A Eazy Tools Module",
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 [Luci_Code]
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.