auto-tools-isee 0.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.
- auto_tools_isee-0.1.0/PKG-INFO +23 -0
- auto_tools_isee-0.1.0/README.md +0 -0
- auto_tools_isee-0.1.0/auto_tools/__init__.py +7 -0
- auto_tools_isee-0.1.0/auto_tools/core.py +81 -0
- auto_tools_isee-0.1.0/auto_tools_isee.egg-info/PKG-INFO +23 -0
- auto_tools_isee-0.1.0/auto_tools_isee.egg-info/SOURCES.txt +11 -0
- auto_tools_isee-0.1.0/auto_tools_isee.egg-info/dependency_links.txt +1 -0
- auto_tools_isee-0.1.0/auto_tools_isee.egg-info/entry_points.txt +2 -0
- auto_tools_isee-0.1.0/auto_tools_isee.egg-info/requires.txt +4 -0
- auto_tools_isee-0.1.0/auto_tools_isee.egg-info/top_level.txt +1 -0
- auto_tools_isee-0.1.0/setup.cfg +4 -0
- auto_tools_isee-0.1.0/setup.py +35 -0
- auto_tools_isee-0.1.0/tests/test_core.py +19 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: auto_tools_isee
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: Advanced string manipulation utilities
|
5
|
+
Home-page:
|
6
|
+
Author: ISEE
|
7
|
+
Author-email: your.email@example.com
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
10
|
+
Classifier: Operating System :: OS Independent
|
11
|
+
Requires-Python: >=3.9
|
12
|
+
Description-Content-Type: text/markdown
|
13
|
+
Requires-Dist: requests>=2.32.3
|
14
|
+
Provides-Extra: dev
|
15
|
+
Requires-Dist: requests>=2.32.3; extra == "dev"
|
16
|
+
Dynamic: author
|
17
|
+
Dynamic: author-email
|
18
|
+
Dynamic: classifier
|
19
|
+
Dynamic: description-content-type
|
20
|
+
Dynamic: provides-extra
|
21
|
+
Dynamic: requires-dist
|
22
|
+
Dynamic: requires-python
|
23
|
+
Dynamic: summary
|
File without changes
|
@@ -0,0 +1,81 @@
|
|
1
|
+
def reverse_string(s: str) -> str:
|
2
|
+
"""
|
3
|
+
反转字符串
|
4
|
+
|
5
|
+
参数:
|
6
|
+
s (str): 需要反转的字符串
|
7
|
+
|
8
|
+
返回:
|
9
|
+
str: 反转后的字符串
|
10
|
+
|
11
|
+
异常:
|
12
|
+
TypeError: 如果输入不是字符串类型,则抛出此异常
|
13
|
+
"""
|
14
|
+
# 类型检查
|
15
|
+
if not isinstance(s, str):
|
16
|
+
raise TypeError("输入必须是字符串类型")
|
17
|
+
|
18
|
+
# 字符串反转逻辑
|
19
|
+
try:
|
20
|
+
return s[::-1]
|
21
|
+
except Exception as e:
|
22
|
+
# 捕获潜在的异常并提供更友好的错误信息
|
23
|
+
raise RuntimeError(f"字符串反转时发生错误: {e}")
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
def count_vowels(s: str) -> int:
|
28
|
+
"""
|
29
|
+
统计字符串中元音字母的数量。
|
30
|
+
|
31
|
+
参数:
|
32
|
+
s (str): 输入字符串。
|
33
|
+
|
34
|
+
返回:
|
35
|
+
int: 元音字母的数量。
|
36
|
+
|
37
|
+
注意:
|
38
|
+
如果输入不是字符串类型,将抛出 ValueError。
|
39
|
+
"""
|
40
|
+
# 定义元音字母集合,提升查找效率
|
41
|
+
VOWELS = set('aeiouAEIOU')
|
42
|
+
|
43
|
+
# 输入验证,确保输入是字符串类型
|
44
|
+
if not isinstance(s, str):
|
45
|
+
raise ValueError("输入必须是字符串类型")
|
46
|
+
|
47
|
+
# 使用生成器表达式统计元音字母数量
|
48
|
+
return sum(1 for char in s if char in VOWELS)
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
def is_palindrome(s: str) -> bool:
|
53
|
+
"""
|
54
|
+
判断给定字符串是否为回文字符串。
|
55
|
+
|
56
|
+
参数:
|
57
|
+
s (str): 输入字符串,可以包含空格和标点符号。
|
58
|
+
|
59
|
+
返回:
|
60
|
+
bool: 如果字符串是回文,则返回 True;否则返回 False。
|
61
|
+
|
62
|
+
注意:
|
63
|
+
1. 忽略大小写。
|
64
|
+
2. 忽略空格和标点符号。
|
65
|
+
3. 空字符串被视为回文。
|
66
|
+
"""
|
67
|
+
if not isinstance(s, str):
|
68
|
+
raise ValueError("输入必须是字符串类型")
|
69
|
+
|
70
|
+
# 过滤掉非字母数字字符,并转换为小写
|
71
|
+
cleaned = ''.join(c.lower() for c in s if c.isalnum())
|
72
|
+
|
73
|
+
# 使用双指针法判断回文
|
74
|
+
left, right = 0, len(cleaned) - 1
|
75
|
+
while left < right:
|
76
|
+
if cleaned[left] != cleaned[right]:
|
77
|
+
return False
|
78
|
+
left += 1
|
79
|
+
right -= 1
|
80
|
+
return True
|
81
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: auto_tools_isee
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: Advanced string manipulation utilities
|
5
|
+
Home-page:
|
6
|
+
Author: ISEE
|
7
|
+
Author-email: your.email@example.com
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
10
|
+
Classifier: Operating System :: OS Independent
|
11
|
+
Requires-Python: >=3.9
|
12
|
+
Description-Content-Type: text/markdown
|
13
|
+
Requires-Dist: requests>=2.32.3
|
14
|
+
Provides-Extra: dev
|
15
|
+
Requires-Dist: requests>=2.32.3; extra == "dev"
|
16
|
+
Dynamic: author
|
17
|
+
Dynamic: author-email
|
18
|
+
Dynamic: classifier
|
19
|
+
Dynamic: description-content-type
|
20
|
+
Dynamic: provides-extra
|
21
|
+
Dynamic: requires-dist
|
22
|
+
Dynamic: requires-python
|
23
|
+
Dynamic: summary
|
@@ -0,0 +1,11 @@
|
|
1
|
+
README.md
|
2
|
+
setup.py
|
3
|
+
auto_tools/__init__.py
|
4
|
+
auto_tools/core.py
|
5
|
+
auto_tools_isee.egg-info/PKG-INFO
|
6
|
+
auto_tools_isee.egg-info/SOURCES.txt
|
7
|
+
auto_tools_isee.egg-info/dependency_links.txt
|
8
|
+
auto_tools_isee.egg-info/entry_points.txt
|
9
|
+
auto_tools_isee.egg-info/requires.txt
|
10
|
+
auto_tools_isee.egg-info/top_level.txt
|
11
|
+
tests/test_core.py
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
auto_tools
|
@@ -0,0 +1,35 @@
|
|
1
|
+
from setuptools import setup, find_packages
|
2
|
+
|
3
|
+
with open("README.md", "r", encoding="utf-8") as fh:
|
4
|
+
long_description = fh.read()
|
5
|
+
|
6
|
+
setup(
|
7
|
+
name="auto_tools_isee", # 包名称(PyPI唯一标识)
|
8
|
+
version="0.1.0", # 初始版本号
|
9
|
+
author="ISEE", # 作者名称
|
10
|
+
author_email="your.email@example.com",
|
11
|
+
description="Advanced string manipulation utilities", # 简短描述
|
12
|
+
long_description=long_description, # 详细说明(从README读取)
|
13
|
+
long_description_content_type="text/markdown",
|
14
|
+
url="", # 项目地址
|
15
|
+
packages=find_packages(), # 自动发现所有包
|
16
|
+
classifiers=[ # 分类器(帮助用户搜索)
|
17
|
+
"Programming Language :: Python :: 3",
|
18
|
+
"License :: OSI Approved :: MIT License",
|
19
|
+
"Operating System :: OS Independent",
|
20
|
+
],
|
21
|
+
python_requires=">=3.9", # Python版本要求
|
22
|
+
install_requires=[ # 依赖库
|
23
|
+
'requests>=2.32.3', # 示例依赖
|
24
|
+
],
|
25
|
+
extras_require={ # 可选依赖
|
26
|
+
'dev': [
|
27
|
+
'requests>=2.32.3'
|
28
|
+
]
|
29
|
+
},
|
30
|
+
entry_points={ # 命令行工具配置
|
31
|
+
'console_scripts': [
|
32
|
+
'strtool=auto_tools.cli:main', # 示例CLI入口
|
33
|
+
],
|
34
|
+
},
|
35
|
+
)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import unittest
|
2
|
+
from auto_tools.core import reverse_string, count_vowels, is_palindrome
|
3
|
+
|
4
|
+
class TestStringUtils(unittest.TestCase):
|
5
|
+
|
6
|
+
def test_reverse(self):
|
7
|
+
result = reverse_string("hello")
|
8
|
+
self.assertEqual(result, "olleh")
|
9
|
+
|
10
|
+
def test_vowel_count(self):
|
11
|
+
result = count_vowels("Python")
|
12
|
+
self.assertEqual(result, 1)
|
13
|
+
|
14
|
+
def test_palindrome(self):
|
15
|
+
result = is_palindrome("A man a plan a canal Panama")
|
16
|
+
self.assertTrue(result) # 假设 is_palindrome 返回 True 表示是回文
|
17
|
+
|
18
|
+
if __name__ == '__main__':
|
19
|
+
unittest.main()
|