vools 0.1.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.
Files changed (65) hide show
  1. vools-0.1.1/LICENSE +31 -0
  2. vools-0.1.1/NOTICE +32 -0
  3. vools-0.1.1/PKG-INFO +334 -0
  4. vools-0.1.1/README.md +264 -0
  5. vools-0.1.1/pyproject.toml +48 -0
  6. vools-0.1.1/setup.cfg +4 -0
  7. vools-0.1.1/setup.py +65 -0
  8. vools-0.1.1/tests/__init__.py +45 -0
  9. vools-0.1.1/tests/test_curried.py +150 -0
  10. vools-0.1.1/tests/test_curry_overload.py +181 -0
  11. vools-0.1.1/tests/test_data.py +60 -0
  12. vools-0.1.1/tests/test_datetime.py +52 -0
  13. vools-0.1.1/tests/test_decorators.py +362 -0
  14. vools-0.1.1/tests/test_functional.py +230 -0
  15. vools-0.1.1/tests/test_functional_simple.py +230 -0
  16. vools-0.1.1/tests/test_main_import.py +70 -0
  17. vools-0.1.1/tests/test_oop.py +51 -0
  18. vools-0.1.1/tests/test_overcurry_vic.py +102 -0
  19. vools-0.1.1/tests/test_placeholder.py +86 -0
  20. vools-0.1.1/tests/test_shotcut.py +232 -0
  21. vools-0.1.1/tests/test_stuff.py +53 -0
  22. vools-0.1.1/tests/test_utils.py +99 -0
  23. vools-0.1.1/tests/test_vools.py +150 -0
  24. vools-0.1.1/vools/__init__.py +299 -0
  25. vools-0.1.1/vools/__main__.py +110 -0
  26. vools-0.1.1/vools/config.py +43 -0
  27. vools-0.1.1/vools/config.template.py +36 -0
  28. vools-0.1.1/vools/data/__init__.py +3 -0
  29. vools-0.1.1/vools/data/seq.py +737 -0
  30. vools-0.1.1/vools/datetime/__init__.py +32 -0
  31. vools-0.1.1/vools/datetime/dates_format.py +921 -0
  32. vools-0.1.1/vools/datetime/utils.py +1130 -0
  33. vools-0.1.1/vools/decorators/__init__.py +119 -0
  34. vools-0.1.1/vools/decorators/cache.py +424 -0
  35. vools-0.1.1/vools/decorators/control.py +377 -0
  36. vools-0.1.1/vools/decorators/curried.py +483 -0
  37. vools-0.1.1/vools/decorators/curry_core.py +440 -0
  38. vools-0.1.1/vools/decorators/curry_delay.py +338 -0
  39. vools-0.1.1/vools/decorators/extend.py +159 -0
  40. vools-0.1.1/vools/decorators/lazy.py +165 -0
  41. vools-0.1.1/vools/decorators/overcurry.py +182 -0
  42. vools-0.1.1/vools/decorators/overload.py +387 -0
  43. vools-0.1.1/vools/decorators/overloads.py +347 -0
  44. vools-0.1.1/vools/decorators/selector.py +255 -0
  45. vools-0.1.1/vools/decorators/trd.py +75 -0
  46. vools-0.1.1/vools/functional/__init__.py +284 -0
  47. vools-0.1.1/vools/functional/arrow_func.py +597 -0
  48. vools-0.1.1/vools/functional/box.py +1275 -0
  49. vools-0.1.1/vools/functional/iif.py +340 -0
  50. vools-0.1.1/vools/functional/placeholder.py +647 -0
  51. vools-0.1.1/vools/oop/__init__.py +25 -0
  52. vools-0.1.1/vools/oop/calltype.py +287 -0
  53. vools-0.1.1/vools/oop/extend.py +911 -0
  54. vools-0.1.1/vools/oop/mixer.py +247 -0
  55. vools-0.1.1/vools/oop/selector.py +39 -0
  56. vools-0.1.1/vools/shotcut.py +554 -0
  57. vools-0.1.1/vools/utils/__init__.py +71 -0
  58. vools-0.1.1/vools/utils/stuff.py +841 -0
  59. vools-0.1.1/vools/vools.py +2496 -0
  60. vools-0.1.1/vools.egg-info/PKG-INFO +334 -0
  61. vools-0.1.1/vools.egg-info/SOURCES.txt +63 -0
  62. vools-0.1.1/vools.egg-info/dependency_links.txt +1 -0
  63. vools-0.1.1/vools.egg-info/entry_points.txt +2 -0
  64. vools-0.1.1/vools.egg-info/requires.txt +11 -0
  65. vools-0.1.1/vools.egg-info/top_level.txt +2 -0
vools-0.1.1/LICENSE ADDED
@@ -0,0 +1,31 @@
1
+ GNU Affero General Public License
2
+ Version 3, 19 November 2007
3
+
4
+ Copyright (C) 2026 Victor
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Affero General Public License as
8
+ published by the Free Software Foundation, either version 3 of the
9
+ License, or (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Affero General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Affero General Public License
17
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+
19
+ ADDITIONAL TERMS:
20
+
21
+ This software is provided for non-commercial use only. Any commercial use
22
+ of this software or its derivatives is strictly prohibited without
23
+ explicit written permission from the copyright holder.
24
+
25
+ Commercial use includes, but is not limited to:
26
+ 1. Selling or licensing the software
27
+ 2. Using the software in a commercial product or service
28
+ 3. Using the software to generate revenue
29
+ 4. Using the software in a for-profit organization
30
+
31
+ For commercial licensing options, please contact the copyright holder.
vools-0.1.1/NOTICE ADDED
@@ -0,0 +1,32 @@
1
+ vools - Python 函数式编程工具集
2
+
3
+ Copyright 2026 Victor
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as
7
+ published by the Free Software Foundation, either version 3 of the
8
+ License, or (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Affero General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Affero General Public License
16
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ ADDITIONAL TERMS:
19
+
20
+ This software is provided for non-commercial use only. Any commercial use
21
+ of this software or its derivatives is strictly prohibited without
22
+ explicit written permission from the copyright holder.
23
+
24
+ Commercial use includes, but is not limited to:
25
+ 1. Selling or licensing the software
26
+ 2. Using the software in a commercial product or service
27
+ 3. Using the software to generate revenue
28
+ 4. Using the software in a for-profit organization
29
+
30
+ For commercial licensing options, please contact the copyright holder.
31
+
32
+ This product includes software developed by the vools project team.
vools-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,334 @@
1
+ Metadata-Version: 2.4
2
+ Name: vools
3
+ Version: 0.1.1
4
+ Summary: Python 函数式编程工具集
5
+ Home-page: https://github.com/vicTop-cw/vools
6
+ Author: Victor
7
+ Author-email: Victor <victortop921129@gmail.com>
8
+ License: GNU Affero General Public License
9
+ Version 3, 19 November 2007
10
+
11
+ Copyright (C) 2026 Victor
12
+
13
+ This program is free software: you can redistribute it and/or modify
14
+ it under the terms of the GNU Affero General Public License as
15
+ published by the Free Software Foundation, either version 3 of the
16
+ License, or (at your option) any later version.
17
+
18
+ This program is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ GNU Affero General Public License for more details.
22
+
23
+ You should have received a copy of the GNU Affero General Public License
24
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
25
+
26
+ ADDITIONAL TERMS:
27
+
28
+ This software is provided for non-commercial use only. Any commercial use
29
+ of this software or its derivatives is strictly prohibited without
30
+ explicit written permission from the copyright holder.
31
+
32
+ Commercial use includes, but is not limited to:
33
+ 1. Selling or licensing the software
34
+ 2. Using the software in a commercial product or service
35
+ 3. Using the software to generate revenue
36
+ 4. Using the software in a for-profit organization
37
+
38
+ For commercial licensing options, please contact the copyright holder.
39
+
40
+ Project-URL: Homepage, https://github.com/vicTop-cw/vools
41
+ Project-URL: Repository, https://github.com/vicTop-cw/vools
42
+ Project-URL: Issues, https://github.com/vicTop-cw/vools/issues
43
+ Classifier: Programming Language :: Python :: 3
44
+ Classifier: Programming Language :: Python :: 3.6
45
+ Classifier: Programming Language :: Python :: 3.7
46
+ Classifier: Programming Language :: Python :: 3.8
47
+ Classifier: Programming Language :: Python :: 3.9
48
+ Classifier: License :: OSI Approved :: Apache Software License
49
+ Classifier: Operating System :: OS Independent
50
+ Classifier: Intended Audience :: Developers
51
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
52
+ Requires-Python: >=3.6
53
+ Description-Content-Type: text/markdown
54
+ License-File: LICENSE
55
+ License-File: NOTICE
56
+ Requires-Dist: wrapt==1.10.11
57
+ Requires-Dist: pandas>=0.22.0
58
+ Requires-Dist: numpy>=1.14.0
59
+ Provides-Extra: dev
60
+ Requires-Dist: pytest==3.3.2; extra == "dev"
61
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
62
+ Requires-Dist: black>=23.0.0; extra == "dev"
63
+ Requires-Dist: isort==4.2.15; extra == "dev"
64
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
65
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
66
+ Dynamic: author
67
+ Dynamic: home-page
68
+ Dynamic: license-file
69
+ Dynamic: requires-python
70
+
71
+ # vools - Python 函数式编程工具集
72
+
73
+ 一个强大的 Python 函数式编程工具集,提供装饰器、函数式编程工具、数据处理工具等。
74
+
75
+ ## 项目结构
76
+
77
+ ```
78
+ vools/
79
+ ├── vools/
80
+ │ ├── data/ # 数据处理工具
81
+ │ │ ├── __init__.py
82
+ │ │ └── seq.py # 序列操作工具
83
+ │ ├── datetime/ # 日期时间工具
84
+ │ │ ├── __init__.py
85
+ │ │ ├── dates_format.py
86
+ │ │ ├── range.py
87
+ │ │ └── utils.py
88
+ │ ├── decorators/ # 装饰器
89
+ │ │ ├── __init__.py
90
+ │ │ ├── cache.py
91
+ │ │ ├── control.py
92
+ │ │ ├── curry.py
93
+ │ │ ├── curry_core.py
94
+ │ │ ├── curry_delay.py
95
+ │ │ ├── extend.py
96
+ │ │ ├── lazy.py
97
+ │ │ ├── overload.py
98
+ │ │ ├── overcurry.py
99
+ │ │ ├── selector.py
100
+ │ │ └── trd.py
101
+ │ ├── functional/ # 函数式编程工具
102
+ │ │ ├── __init__.py
103
+ │ │ ├── arrow_func.py
104
+ │ │ ├── box.py
105
+ │ │ └── placeholder.py
106
+ │ ├── oop/ # OOP 工具
107
+ │ │ ├── __init__.py
108
+ │ │ ├── calltype.py
109
+ │ │ ├── extend.py
110
+ │ │ └── selector.py
111
+ │ ├── utils/ # 通用工具
112
+ │ │ ├── __init__.py
113
+ │ │ └── stuff.py
114
+ │ ├── __init__.py
115
+ │ └── vools.py # 核心功能
116
+ ├── tests/ # 测试文件
117
+ │ ├── __init__.py
118
+ │ ├── test_curried.py
119
+ │ ├── test_curry_overload.py
120
+ │ ├── test_data.py
121
+ │ ├── test_datetime.py
122
+ │ ├── test_decorators.py
123
+ │ ├── test_functional.py
124
+ │ ├── test_functional_simple.py
125
+ │ ├── test_oop.py
126
+ │ ├── test_overcurry_vic.py
127
+ │ ├── test_placeholder.py
128
+ │ ├── test_shotcut.py
129
+ │ ├── test_utils.py
130
+ │ └── test_vools.py
131
+ ├── .gitignore
132
+ ├── LICENSE
133
+ ├── NOTICE
134
+ ├── README.md
135
+ ├── requirements.txt
136
+ ├── setup.py
137
+ └── USER_GUIDE.md
138
+ ```
139
+
140
+ ## 安装指南
141
+
142
+ ### 环境要求
143
+
144
+ - Python 3.6+
145
+
146
+ ### 安装方法
147
+
148
+ 1. 克隆项目
149
+
150
+ ```bash
151
+ git clone https://github.com/vicTop-cw/vools.git
152
+ cd vools
153
+ ```
154
+
155
+ 2. 安装依赖
156
+
157
+ ```bash
158
+ pip install -r requirements.txt
159
+ ```
160
+
161
+ 3. 配置设置
162
+
163
+ 复制配置模板并填写相应的配置值:
164
+
165
+ ```bash
166
+ cp vools/config.template.py vools/config.py
167
+ # 编辑 vools/config.py 文件,填写配置值
168
+ ```
169
+
170
+ 或者通过环境变量设置配置:
171
+
172
+ ```bash
173
+ # 示例环境变量设置
174
+ # export CACHE_DURATION=300
175
+ ```
176
+
177
+ ## 用法指南
178
+
179
+ ### 装饰器
180
+
181
+ ```python
182
+ from vools import memorize, once, repeat, retry
183
+
184
+ # 缓存装饰器
185
+ @memorize(duration=60) # 缓存 60 秒
186
+ def expensive_function(x):
187
+ return x ** 2
188
+
189
+ # 只执行一次
190
+ @once
191
+ def initialize():
192
+ print("初始化...")
193
+ return 42
194
+
195
+ # 重复执行
196
+ @repeat(cnt=3, delay=0.1)
197
+ def hello(name):
198
+ return f"Hello, {name}!"
199
+
200
+ # 重试装饰器
201
+ @retry(times=3, delay=1)
202
+ def risky_operation():
203
+ # 可能失败的操作
204
+ pass
205
+ ```
206
+
207
+ ### 函数式编程工具
208
+
209
+ ```python
210
+ from vools import Pipe, Ops, Seq, P
211
+
212
+ # 使用 Pipe
213
+ result = range(10) | Pipe(lambda x: [i * 2 for i in x]) | Pipe(list)
214
+
215
+ # 使用 Ops
216
+ result = range(10) | Ops.filter(lambda x: x % 2 == 0) | Ops.map(lambda x: x * 2) | Ops.sum()
217
+
218
+ # 使用 Seq
219
+ result = Seq(range(10)).map(lambda x: x * 2).filter(lambda x: x > 5).collect()
220
+
221
+ # 使用 P
222
+ result = [1, 2, 3] | P(sum)
223
+ ```
224
+
225
+ ### 数据处理工具
226
+
227
+ ```python
228
+ from vools import Seq
229
+
230
+ # 创建序列并进行操作
231
+ result = Seq(range(10))\
232
+ .map(lambda x: x * 2)\
233
+ .filter(lambda x: x > 5)\
234
+ .map(lambda x: x + 1)\
235
+ .collect()
236
+
237
+ print(result) # 输出: [7, 9, 11, 13, 15, 17, 19]
238
+
239
+ # 链式操作
240
+ result = Seq([1, 2, 3, 4, 5])\
241
+ .map(lambda x: x ** 2)\
242
+ .filter(lambda x: x > 10)\
243
+ .collect()
244
+
245
+ print(result) # 输出: [16, 25]
246
+ ```
247
+
248
+ ### 配置管理
249
+
250
+ ```python
251
+ from vools import config
252
+
253
+ # 获取配置
254
+ cache_duration = config.get('OTHER_CONFIG.cache_duration', 5) # 默认值 5
255
+
256
+ # 设置配置
257
+ config.set('OTHER_CONFIG.max_workers', 20)
258
+
259
+ # 验证配置
260
+ config.validate()
261
+ ```
262
+
263
+ ## API 文档
264
+
265
+ ### 装饰器模块
266
+
267
+ - `memorize(duration=300)`: 缓存函数结果
268
+ - `once()`: 函数只执行一次
269
+ - `lazy()`: 延迟执行函数
270
+ - `repeat(cnt=1, delay=0)`: 重复执行函数
271
+ - `retry(times=3, delay=1)`: 失败时重试
272
+ - `rerun(interval=1, times=-1)`: 定时重复执行
273
+ - `trd()`: 线程执行
274
+ - `proc()`: 进程执行
275
+ - `extend()`: 函数扩展
276
+ - `curry()`: 柯里化
277
+ - `delay_curry()`: 延迟柯里化
278
+ - `overload()`: 函数重载
279
+
280
+ ### 函数式编程模块
281
+
282
+ - `Pipe(func)`: 管道操作
283
+ - `Ops`: 操作符集合(filter, map, sum, all, any, min, max, take, drop, distinct, count, as_list, do)
284
+ - `Seq(iterable)`: 序列操作(map, filter, collect)
285
+ - `P(func)`: 可管道化函数包装器
286
+ - `NONE`: 空值标记
287
+
288
+ ### 数据处理模块
289
+
290
+ - `box(obj)`: 将对象包装为 Box 对象,提供链式操作
291
+ - `Box(obj)`: Box 类,用于包装对象并提供链式操作
292
+
293
+ ### 配置管理
294
+
295
+ - `config.get(key, default=None)`: 获取配置值
296
+ - `config.set(key, value)`: 设置配置值
297
+ - `config.get_all()`: 获取所有配置
298
+ - `config.validate()`: 验证配置
299
+
300
+ ## 贡献指南
301
+
302
+ 1. Fork 项目
303
+ 2. 创建功能分支 (`git checkout -b feature/AmazingFeature`)
304
+ 3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
305
+ 4. 推送到分支 (`git push origin feature/AmazingFeature`)
306
+ 5. 打开 Pull Request
307
+
308
+ ### 代码规范
309
+
310
+ - 遵循 PEP 8 代码风格
311
+ - 使用 Black 进行代码格式化
312
+ - 使用 isort 进行导入排序
313
+ - 为所有公共函数添加文档字符串
314
+ - 为新功能添加测试
315
+
316
+ ## 许可证
317
+
318
+ 本项目采用 Apache 2.0 许可证 - 详见 [LICENSE](LICENSE) 文件
319
+
320
+ ## 联系方式
321
+
322
+ - 作者: Victor
323
+ - 邮箱: victortop921129@gmail.com
324
+ - 项目链接: https://github.com/vicTop-cw/vools
325
+
326
+ ## 更新日志
327
+
328
+ ### v0.1.0
329
+ - 初始版本
330
+ - 实现装饰器模块
331
+ - 实现函数式编程工具
332
+ - 实现数据处理工具
333
+ - 实现配置管理
334
+ - 添加基本测试
vools-0.1.1/README.md ADDED
@@ -0,0 +1,264 @@
1
+ # vools - Python 函数式编程工具集
2
+
3
+ 一个强大的 Python 函数式编程工具集,提供装饰器、函数式编程工具、数据处理工具等。
4
+
5
+ ## 项目结构
6
+
7
+ ```
8
+ vools/
9
+ ├── vools/
10
+ │ ├── data/ # 数据处理工具
11
+ │ │ ├── __init__.py
12
+ │ │ └── seq.py # 序列操作工具
13
+ │ ├── datetime/ # 日期时间工具
14
+ │ │ ├── __init__.py
15
+ │ │ ├── dates_format.py
16
+ │ │ ├── range.py
17
+ │ │ └── utils.py
18
+ │ ├── decorators/ # 装饰器
19
+ │ │ ├── __init__.py
20
+ │ │ ├── cache.py
21
+ │ │ ├── control.py
22
+ │ │ ├── curry.py
23
+ │ │ ├── curry_core.py
24
+ │ │ ├── curry_delay.py
25
+ │ │ ├── extend.py
26
+ │ │ ├── lazy.py
27
+ │ │ ├── overload.py
28
+ │ │ ├── overcurry.py
29
+ │ │ ├── selector.py
30
+ │ │ └── trd.py
31
+ │ ├── functional/ # 函数式编程工具
32
+ │ │ ├── __init__.py
33
+ │ │ ├── arrow_func.py
34
+ │ │ ├── box.py
35
+ │ │ └── placeholder.py
36
+ │ ├── oop/ # OOP 工具
37
+ │ │ ├── __init__.py
38
+ │ │ ├── calltype.py
39
+ │ │ ├── extend.py
40
+ │ │ └── selector.py
41
+ │ ├── utils/ # 通用工具
42
+ │ │ ├── __init__.py
43
+ │ │ └── stuff.py
44
+ │ ├── __init__.py
45
+ │ └── vools.py # 核心功能
46
+ ├── tests/ # 测试文件
47
+ │ ├── __init__.py
48
+ │ ├── test_curried.py
49
+ │ ├── test_curry_overload.py
50
+ │ ├── test_data.py
51
+ │ ├── test_datetime.py
52
+ │ ├── test_decorators.py
53
+ │ ├── test_functional.py
54
+ │ ├── test_functional_simple.py
55
+ │ ├── test_oop.py
56
+ │ ├── test_overcurry_vic.py
57
+ │ ├── test_placeholder.py
58
+ │ ├── test_shotcut.py
59
+ │ ├── test_utils.py
60
+ │ └── test_vools.py
61
+ ├── .gitignore
62
+ ├── LICENSE
63
+ ├── NOTICE
64
+ ├── README.md
65
+ ├── requirements.txt
66
+ ├── setup.py
67
+ └── USER_GUIDE.md
68
+ ```
69
+
70
+ ## 安装指南
71
+
72
+ ### 环境要求
73
+
74
+ - Python 3.6+
75
+
76
+ ### 安装方法
77
+
78
+ 1. 克隆项目
79
+
80
+ ```bash
81
+ git clone https://github.com/vicTop-cw/vools.git
82
+ cd vools
83
+ ```
84
+
85
+ 2. 安装依赖
86
+
87
+ ```bash
88
+ pip install -r requirements.txt
89
+ ```
90
+
91
+ 3. 配置设置
92
+
93
+ 复制配置模板并填写相应的配置值:
94
+
95
+ ```bash
96
+ cp vools/config.template.py vools/config.py
97
+ # 编辑 vools/config.py 文件,填写配置值
98
+ ```
99
+
100
+ 或者通过环境变量设置配置:
101
+
102
+ ```bash
103
+ # 示例环境变量设置
104
+ # export CACHE_DURATION=300
105
+ ```
106
+
107
+ ## 用法指南
108
+
109
+ ### 装饰器
110
+
111
+ ```python
112
+ from vools import memorize, once, repeat, retry
113
+
114
+ # 缓存装饰器
115
+ @memorize(duration=60) # 缓存 60 秒
116
+ def expensive_function(x):
117
+ return x ** 2
118
+
119
+ # 只执行一次
120
+ @once
121
+ def initialize():
122
+ print("初始化...")
123
+ return 42
124
+
125
+ # 重复执行
126
+ @repeat(cnt=3, delay=0.1)
127
+ def hello(name):
128
+ return f"Hello, {name}!"
129
+
130
+ # 重试装饰器
131
+ @retry(times=3, delay=1)
132
+ def risky_operation():
133
+ # 可能失败的操作
134
+ pass
135
+ ```
136
+
137
+ ### 函数式编程工具
138
+
139
+ ```python
140
+ from vools import Pipe, Ops, Seq, P
141
+
142
+ # 使用 Pipe
143
+ result = range(10) | Pipe(lambda x: [i * 2 for i in x]) | Pipe(list)
144
+
145
+ # 使用 Ops
146
+ result = range(10) | Ops.filter(lambda x: x % 2 == 0) | Ops.map(lambda x: x * 2) | Ops.sum()
147
+
148
+ # 使用 Seq
149
+ result = Seq(range(10)).map(lambda x: x * 2).filter(lambda x: x > 5).collect()
150
+
151
+ # 使用 P
152
+ result = [1, 2, 3] | P(sum)
153
+ ```
154
+
155
+ ### 数据处理工具
156
+
157
+ ```python
158
+ from vools import Seq
159
+
160
+ # 创建序列并进行操作
161
+ result = Seq(range(10))\
162
+ .map(lambda x: x * 2)\
163
+ .filter(lambda x: x > 5)\
164
+ .map(lambda x: x + 1)\
165
+ .collect()
166
+
167
+ print(result) # 输出: [7, 9, 11, 13, 15, 17, 19]
168
+
169
+ # 链式操作
170
+ result = Seq([1, 2, 3, 4, 5])\
171
+ .map(lambda x: x ** 2)\
172
+ .filter(lambda x: x > 10)\
173
+ .collect()
174
+
175
+ print(result) # 输出: [16, 25]
176
+ ```
177
+
178
+ ### 配置管理
179
+
180
+ ```python
181
+ from vools import config
182
+
183
+ # 获取配置
184
+ cache_duration = config.get('OTHER_CONFIG.cache_duration', 5) # 默认值 5
185
+
186
+ # 设置配置
187
+ config.set('OTHER_CONFIG.max_workers', 20)
188
+
189
+ # 验证配置
190
+ config.validate()
191
+ ```
192
+
193
+ ## API 文档
194
+
195
+ ### 装饰器模块
196
+
197
+ - `memorize(duration=300)`: 缓存函数结果
198
+ - `once()`: 函数只执行一次
199
+ - `lazy()`: 延迟执行函数
200
+ - `repeat(cnt=1, delay=0)`: 重复执行函数
201
+ - `retry(times=3, delay=1)`: 失败时重试
202
+ - `rerun(interval=1, times=-1)`: 定时重复执行
203
+ - `trd()`: 线程执行
204
+ - `proc()`: 进程执行
205
+ - `extend()`: 函数扩展
206
+ - `curry()`: 柯里化
207
+ - `delay_curry()`: 延迟柯里化
208
+ - `overload()`: 函数重载
209
+
210
+ ### 函数式编程模块
211
+
212
+ - `Pipe(func)`: 管道操作
213
+ - `Ops`: 操作符集合(filter, map, sum, all, any, min, max, take, drop, distinct, count, as_list, do)
214
+ - `Seq(iterable)`: 序列操作(map, filter, collect)
215
+ - `P(func)`: 可管道化函数包装器
216
+ - `NONE`: 空值标记
217
+
218
+ ### 数据处理模块
219
+
220
+ - `box(obj)`: 将对象包装为 Box 对象,提供链式操作
221
+ - `Box(obj)`: Box 类,用于包装对象并提供链式操作
222
+
223
+ ### 配置管理
224
+
225
+ - `config.get(key, default=None)`: 获取配置值
226
+ - `config.set(key, value)`: 设置配置值
227
+ - `config.get_all()`: 获取所有配置
228
+ - `config.validate()`: 验证配置
229
+
230
+ ## 贡献指南
231
+
232
+ 1. Fork 项目
233
+ 2. 创建功能分支 (`git checkout -b feature/AmazingFeature`)
234
+ 3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
235
+ 4. 推送到分支 (`git push origin feature/AmazingFeature`)
236
+ 5. 打开 Pull Request
237
+
238
+ ### 代码规范
239
+
240
+ - 遵循 PEP 8 代码风格
241
+ - 使用 Black 进行代码格式化
242
+ - 使用 isort 进行导入排序
243
+ - 为所有公共函数添加文档字符串
244
+ - 为新功能添加测试
245
+
246
+ ## 许可证
247
+
248
+ 本项目采用 Apache 2.0 许可证 - 详见 [LICENSE](LICENSE) 文件
249
+
250
+ ## 联系方式
251
+
252
+ - 作者: Victor
253
+ - 邮箱: victortop921129@gmail.com
254
+ - 项目链接: https://github.com/vicTop-cw/vools
255
+
256
+ ## 更新日志
257
+
258
+ ### v0.1.0
259
+ - 初始版本
260
+ - 实现装饰器模块
261
+ - 实现函数式编程工具
262
+ - 实现数据处理工具
263
+ - 实现配置管理
264
+ - 添加基本测试
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "vools"
7
+ dynamic = ["version"]
8
+ authors = [
9
+ { name = "Victor", email = "victortop921129@gmail.com" },
10
+ ]
11
+ description = "Python 函数式编程工具集"
12
+ readme = "README.md"
13
+ license = { file = "LICENSE" }
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.6",
17
+ "Programming Language :: Python :: 3.7",
18
+ "Programming Language :: Python :: 3.8",
19
+ "Programming Language :: Python :: 3.9",
20
+ "License :: OSI Approved :: Apache Software License",
21
+ "Operating System :: OS Independent",
22
+ "Intended Audience :: Developers",
23
+ "Topic :: Software Development :: Libraries :: Python Modules",
24
+ ]
25
+ requires-python = ">=3.6"
26
+ dependencies = [
27
+ "wrapt==1.10.11",
28
+ "pandas>=0.22.0",
29
+ "numpy>=1.14.0",
30
+ ]
31
+
32
+ [project.optional-dependencies]
33
+ dev = [
34
+ "pytest==3.3.2",
35
+ "pytest-cov>=4.0.0",
36
+ "black>=23.0.0",
37
+ "isort==4.2.15",
38
+ "flake8>=6.0.0",
39
+ "mypy>=1.0.0",
40
+ ]
41
+
42
+ [project.scripts]
43
+ vools = "vools.__main__:main"
44
+
45
+ [project.urls]
46
+ "Homepage" = "https://github.com/vicTop-cw/vools"
47
+ "Repository" = "https://github.com/vicTop-cw/vools"
48
+ "Issues" = "https://github.com/vicTop-cw/vools/issues"
vools-0.1.1/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+