vools 0.1.2__tar.gz → 0.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.
Files changed (67) hide show
  1. {vools-0.1.2/vools.egg-info → vools-0.1.4}/PKG-INFO +1 -1
  2. {vools-0.1.2 → vools-0.1.4}/setup.py +1 -1
  3. {vools-0.1.2 → vools-0.1.4}/vools/__init__.py +139 -120
  4. {vools-0.1.2 → vools-0.1.4/vools.egg-info}/PKG-INFO +1 -1
  5. {vools-0.1.2 → vools-0.1.4}/LICENSE +0 -0
  6. {vools-0.1.2 → vools-0.1.4}/NOTICE +0 -0
  7. {vools-0.1.2 → vools-0.1.4}/README.md +0 -0
  8. {vools-0.1.2 → vools-0.1.4}/pyproject.toml +0 -0
  9. {vools-0.1.2 → vools-0.1.4}/setup.cfg +0 -0
  10. {vools-0.1.2 → vools-0.1.4}/tests/__init__.py +0 -0
  11. {vools-0.1.2 → vools-0.1.4}/tests/test_curried.py +0 -0
  12. {vools-0.1.2 → vools-0.1.4}/tests/test_curry_overload.py +0 -0
  13. {vools-0.1.2 → vools-0.1.4}/tests/test_data.py +0 -0
  14. {vools-0.1.2 → vools-0.1.4}/tests/test_datetime.py +0 -0
  15. {vools-0.1.2 → vools-0.1.4}/tests/test_decorators.py +0 -0
  16. {vools-0.1.2 → vools-0.1.4}/tests/test_functional.py +0 -0
  17. {vools-0.1.2 → vools-0.1.4}/tests/test_functional_simple.py +0 -0
  18. {vools-0.1.2 → vools-0.1.4}/tests/test_import.py +0 -0
  19. {vools-0.1.2 → vools-0.1.4}/tests/test_main_import.py +0 -0
  20. {vools-0.1.2 → vools-0.1.4}/tests/test_oop.py +0 -0
  21. {vools-0.1.2 → vools-0.1.4}/tests/test_overcurry_vic.py +0 -0
  22. {vools-0.1.2 → vools-0.1.4}/tests/test_placeholder.py +0 -0
  23. {vools-0.1.2 → vools-0.1.4}/tests/test_shotcut.py +0 -0
  24. {vools-0.1.2 → vools-0.1.4}/tests/test_stuff.py +0 -0
  25. {vools-0.1.2 → vools-0.1.4}/tests/test_utils.py +0 -0
  26. {vools-0.1.2 → vools-0.1.4}/tests/test_vools.py +0 -0
  27. {vools-0.1.2 → vools-0.1.4}/vools/__main__.py +0 -0
  28. {vools-0.1.2 → vools-0.1.4}/vools/config.py +0 -0
  29. {vools-0.1.2 → vools-0.1.4}/vools/config.template.py +0 -0
  30. {vools-0.1.2 → vools-0.1.4}/vools/data/__init__.py +0 -0
  31. {vools-0.1.2 → vools-0.1.4}/vools/data/seq.py +0 -0
  32. {vools-0.1.2 → vools-0.1.4}/vools/datetime/__init__.py +0 -0
  33. {vools-0.1.2 → vools-0.1.4}/vools/datetime/dates_format.py +0 -0
  34. {vools-0.1.2 → vools-0.1.4}/vools/datetime/utils.py +0 -0
  35. {vools-0.1.2 → vools-0.1.4}/vools/decorators/__init__.py +0 -0
  36. {vools-0.1.2 → vools-0.1.4}/vools/decorators/cache.py +0 -0
  37. {vools-0.1.2 → vools-0.1.4}/vools/decorators/control.py +0 -0
  38. {vools-0.1.2 → vools-0.1.4}/vools/decorators/curried.py +0 -0
  39. {vools-0.1.2 → vools-0.1.4}/vools/decorators/curry_core.py +0 -0
  40. {vools-0.1.2 → vools-0.1.4}/vools/decorators/curry_delay.py +0 -0
  41. {vools-0.1.2 → vools-0.1.4}/vools/decorators/extend.py +0 -0
  42. {vools-0.1.2 → vools-0.1.4}/vools/decorators/lazy.py +0 -0
  43. {vools-0.1.2 → vools-0.1.4}/vools/decorators/overcurry.py +0 -0
  44. {vools-0.1.2 → vools-0.1.4}/vools/decorators/overload.py +0 -0
  45. {vools-0.1.2 → vools-0.1.4}/vools/decorators/overloads.py +0 -0
  46. {vools-0.1.2 → vools-0.1.4}/vools/decorators/selector.py +0 -0
  47. {vools-0.1.2 → vools-0.1.4}/vools/decorators/trd.py +0 -0
  48. {vools-0.1.2 → vools-0.1.4}/vools/functional/__init__.py +0 -0
  49. {vools-0.1.2 → vools-0.1.4}/vools/functional/arrow_func.py +0 -0
  50. {vools-0.1.2 → vools-0.1.4}/vools/functional/box.py +0 -0
  51. {vools-0.1.2 → vools-0.1.4}/vools/functional/funcs.py +0 -0
  52. {vools-0.1.2 → vools-0.1.4}/vools/functional/iif.py +0 -0
  53. {vools-0.1.2 → vools-0.1.4}/vools/functional/placeholder.py +0 -0
  54. {vools-0.1.2 → vools-0.1.4}/vools/oop/__init__.py +0 -0
  55. {vools-0.1.2 → vools-0.1.4}/vools/oop/calltype.py +0 -0
  56. {vools-0.1.2 → vools-0.1.4}/vools/oop/extend.py +0 -0
  57. {vools-0.1.2 → vools-0.1.4}/vools/oop/mixer.py +0 -0
  58. {vools-0.1.2 → vools-0.1.4}/vools/oop/selector.py +0 -0
  59. {vools-0.1.2 → vools-0.1.4}/vools/shotcut.py +0 -0
  60. {vools-0.1.2 → vools-0.1.4}/vools/utils/__init__.py +0 -0
  61. {vools-0.1.2 → vools-0.1.4}/vools/utils/stuff.py +0 -0
  62. {vools-0.1.2 → vools-0.1.4}/vools/vools.py +0 -0
  63. {vools-0.1.2 → vools-0.1.4}/vools.egg-info/SOURCES.txt +0 -0
  64. {vools-0.1.2 → vools-0.1.4}/vools.egg-info/dependency_links.txt +0 -0
  65. {vools-0.1.2 → vools-0.1.4}/vools.egg-info/entry_points.txt +0 -0
  66. {vools-0.1.2 → vools-0.1.4}/vools.egg-info/requires.txt +0 -0
  67. {vools-0.1.2 → vools-0.1.4}/vools.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vools
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: Python 函数式编程工具集
5
5
  Home-page: https://github.com/vicTop-cw/vools
6
6
  Author: Victor
@@ -43,7 +43,7 @@ setup(
43
43
  ],
44
44
  python_requires=">=3.6",
45
45
  install_requires=[
46
- "wrapt>=1.10.11",
46
+ "wrapt>=2.1.2",
47
47
  "pandas>=0.22.0",
48
48
  "numpy>=1.14.0",
49
49
  ],
@@ -1,18 +1,20 @@
1
1
  """
2
2
  vools - Python 函数式编程工具集
3
3
 
4
- 一个强大的 Python 函数式编程工具集,提供装饰器、函数式编程工具、数据处理工具等。
5
- """
4
+ 一个强大的 Python 函数式编程工具集,提供装饰器、函数式编程工具、数据处理工具等。"""
5
+
6
+ import importlib
7
+ import os
8
+ import pkgutil
6
9
 
7
10
  # ============================================================================
8
11
  # 版本信息
9
12
  # ============================================================================
10
13
 
11
- __version__ = "0.1.2"
14
+ __version__ = "0.1.4"
12
15
  __author__ = "Victor"
13
16
  __license__ = "Apache 2.0"
14
17
 
15
-
16
18
  # ============================================================================
17
19
  # 导入子模块
18
20
  # ============================================================================
@@ -20,101 +22,111 @@ __license__ = "Apache 2.0"
20
22
  # 配置管理
21
23
  from .config import config, ConfigManager
22
24
 
23
- # 装饰器
24
- from .decorators import (
25
- memorize,
26
- once,
27
- persist,
28
- lazy,
29
- repeat,
30
- retry,
31
- rerun,
32
- trd,
33
- proc,
34
- extend,
35
- curry,
36
- delay_curry,
37
- overload,
38
- overcurry,
39
- overloads,
40
- )
41
-
42
- # 函数式编程工具
43
- from .functional import (
44
- Pipe,
45
- Ops,
46
- Seq,
47
- P,
48
- NONE,
49
- iif,
50
- ConditionBuilder,
51
- LazyProperty,
52
- arrow_func,
53
- g,
54
- _,
55
- _1,
56
- _2,
57
- _3,
58
- )
59
-
60
- # 通用工具
61
- from .utils import (
62
- stuff,
63
- Stuff,
64
- IndexedDict,
65
- identity,
66
- const,
67
- compose,
68
- pipe,
69
- )
70
-
71
- # 快捷工具
72
- from .shotcut import (
73
- shotcut,
74
- shotcutEx,
75
- hoder,
76
- Hoder,
77
- timeit,
78
- memoize,
79
- once,
80
- retry,
81
- asyncify,
82
- compose,
83
- pipe,
84
- smart_partial,
85
- safe,
86
- throttle,
87
- debounce,
88
- singleton,
89
- deprecated,
90
- conditional,
91
- with_context,
92
- with_timeout,
93
- validate,
94
- rate_limit,
95
- log_calls,
96
- cache_with_ttl,
97
- hybrid_method,
98
- classproperty,
99
- enumize,
100
- )
101
-
102
- # 数据处理工具(可选)
25
+ # 定义子包优先级(优先级高的会覆盖优先级低的)
26
+ SUBPACKAGE_PRIORITIES = [
27
+ 'shotcut', # 最高优先级
28
+ 'vools',
29
+ 'functional',
30
+ 'decorators',
31
+ 'utils',
32
+ 'oop',
33
+ 'data',
34
+ 'datetime', # 最低优先级
35
+ ]
36
+
37
+ # 存储导入的对象
38
+ _imported_objects = {}
39
+
40
+ # 获取所有子包
41
+ def _get_subpackages():
42
+ """获取所有子包"""
43
+ subpackages = []
44
+ package_path = os.path.dirname(__file__)
45
+ for _, name, is_pkg in pkgutil.iter_modules([package_path]):
46
+ if is_pkg and name not in ['__pycache__']:
47
+ subpackages.append(name)
48
+ return subpackages
49
+
50
+ # 从子包导入对象
51
+ def _import_from_subpackage(subpackage_name):
52
+ """从子包导入对象"""
53
+ try:
54
+ # 导入子包
55
+ subpackage = importlib.import_module(f'.{subpackage_name}', package='vools')
56
+
57
+ # 获取子包的 __all__ 列表
58
+ if hasattr(subpackage, '__all__'):
59
+ all_objects = subpackage.__all__
60
+ else:
61
+ # 如果没有 __all__,则导入所有非下划线开头的对象
62
+ all_objects = [name for name in dir(subpackage) if not name.startswith('_')]
63
+
64
+ # 导入对象
65
+ for obj_name in all_objects:
66
+ if hasattr(subpackage, obj_name):
67
+ obj = getattr(subpackage, obj_name)
68
+
69
+ # 检查是否已有同名对象
70
+ if obj_name in _imported_objects:
71
+ # 优先级检查,保持高优先级的对象
72
+ existing_priority = SUBPACKAGE_PRIORITIES.index(_imported_objects[obj_name]['package'])
73
+ current_priority = SUBPACKAGE_PRIORITIES.index(subpackage_name)
74
+
75
+ if current_priority < existing_priority:
76
+ # 当前包优先级更高,覆盖现有对象
77
+ _imported_objects[obj_name] = {
78
+ 'object': obj,
79
+ 'package': subpackage_name
80
+ }
81
+ else:
82
+ # 新对象,直接导入
83
+ _imported_objects[obj_name] = {
84
+ 'object': obj,
85
+ 'package': subpackage_name
86
+ }
87
+ except Exception:
88
+ # 静默处理导入错误,避免干扰用户
89
+ pass
90
+
91
+ # 导入所有子包
92
+ subpackages = _get_subpackages()
93
+ for subpackage in SUBPACKAGE_PRIORITIES:
94
+ if subpackage in subpackages:
95
+ _import_from_subpackage(subpackage)
96
+
97
+ # 将导入的对象添加到模块命名空间
98
+ for obj_name, info in _imported_objects.items():
99
+ globals()[obj_name] = info['object']
100
+
101
+ # 特殊处理:导入 config 和 ConfigManager
102
+ globals()['config'] = config
103
+ globals()['ConfigManager'] = ConfigManager
104
+
105
+ # 特殊处理:导入 curry_overloads
106
+ try:
107
+ from .oop import overloads as curry_overloads
108
+ globals()['curry_overloads'] = curry_overloads
109
+ except ImportError:
110
+ pass
111
+
112
+ # 可选导入
113
+ # 数据处理工具
103
114
  try:
104
115
  from . import data
105
116
  DATA_AVAILABLE = True
117
+ globals()['data'] = data
106
118
  except Exception:
107
119
  DATA_AVAILABLE = False
108
120
 
109
- # OOP 工具(可选)
121
+ # OOP 工具
110
122
  try:
111
123
  from . import oop
112
- from .oop import Selector, overloads as curry_overloads, Mixer, mixer
113
124
  OOP_AVAILABLE = True
125
+ globals()['oop'] = oop
114
126
  except ImportError:
115
127
  OOP_AVAILABLE = False
116
128
 
117
- # 自定义数据类型(可选)
129
+ # 自定义数据类型
118
130
  try:
119
131
  from .vools import (
120
132
  vicTools,
@@ -123,21 +135,21 @@ try:
123
135
  vicList,
124
136
  )
125
137
  VIC_AVAILABLE = True
138
+ globals()['vicTools'] = vicTools
139
+ globals()['vicDate'] = vicDate
140
+ globals()['vicText'] = vicText
141
+ globals()['vicList'] = vicList
126
142
  except Exception:
127
143
  VIC_AVAILABLE = False
128
144
 
129
-
130
-
131
- # 日期时间工具(可选)
145
+ # 日期时间工具
132
146
  try:
133
147
  from . import datetime
134
148
  DATETIME_AVAILABLE = True
149
+ globals()['datetime'] = datetime
135
150
  except ImportError:
136
151
  DATETIME_AVAILABLE = False
137
152
 
138
-
139
-
140
-
141
153
  # ============================================================================
142
154
  # 公共 API
143
155
  # ============================================================================
@@ -147,11 +159,11 @@ __all__ = [
147
159
  '__version__',
148
160
  '__author__',
149
161
  '__license__',
150
-
162
+
151
163
  # 配置管理
152
164
  'config',
153
165
  'ConfigManager',
154
-
166
+
155
167
  # 装饰器
156
168
  'memorize',
157
169
  'once',
@@ -167,7 +179,8 @@ __all__ = [
167
179
  'delay_curry',
168
180
  'overload',
169
181
  'overcurry',
170
-
182
+ 'overloads',
183
+
171
184
  # 函数式编程工具
172
185
  'Pipe',
173
186
  'Ops',
@@ -179,7 +192,11 @@ __all__ = [
179
192
  'LazyProperty',
180
193
  'arrow_func',
181
194
  'g',
182
-
195
+ '_',
196
+ '_1',
197
+ '_2',
198
+ '_3',
199
+
183
200
  # 通用工具
184
201
  'stuff',
185
202
  'Stuff',
@@ -188,7 +205,7 @@ __all__ = [
188
205
  'const',
189
206
  'compose',
190
207
  'pipe',
191
-
208
+
192
209
  # 快捷工具
193
210
  'shotcut',
194
211
  'shotcutEx',
@@ -211,36 +228,38 @@ __all__ = [
211
228
  'hybrid_method',
212
229
  'classproperty',
213
230
  'enumize',
214
-
231
+
215
232
  # 面向对象工具
216
233
  'Selector',
217
- 'overloads',
218
234
  'Mixer',
219
235
  'mixer',
220
-
236
+
221
237
  # 自定义数据类型
222
238
  'vicTools',
223
239
  'vicDate',
224
240
  'vicText',
225
241
  'vicList',
226
-
227
-
242
+
243
+
228
244
  # 数据处理工具
229
245
  'data',
230
246
  'DATA_AVAILABLE',
231
-
247
+
232
248
  # OOP 工具
233
249
  'oop',
234
250
  'OOP_AVAILABLE',
235
251
  'curry_overloads',
236
-
252
+
237
253
  # 日期时间工具
238
254
  'datetime',
239
255
  'DATETIME_AVAILABLE',
240
-
241
256
 
242
257
  ]
243
258
 
259
+ # 确保 __all__ 中的所有名称都在模块命名空间中
260
+ for name in __all__:
261
+ if name not in globals() and not name.startswith('__'):
262
+ globals()[name] = None
244
263
 
245
264
  # ============================================================================
246
265
  # 便捷导入
@@ -256,48 +275,48 @@ __all__ = [
256
275
  if __name__ == '__main__':
257
276
  print(f"vools version: {__version__}")
258
277
  print(f"Available exports: {__all__}")
259
-
278
+
260
279
  # 测试装饰器
261
280
  print("\n=== 测试 memorize ===")
262
-
281
+
263
282
  @memorize(duration=5)
264
283
  def expensive_function(x):
265
284
  return x ** 2
266
-
285
+
267
286
  print(f"expensive_function(5) = {expensive_function(5)}")
268
287
  print(f"expensive_function(5) = {expensive_function(5)} (cached)")
269
-
288
+
270
289
  # 测试 once
271
290
  print("\n=== 测试 once ===")
272
-
291
+
273
292
  @once
274
293
  def initialize():
275
294
  print("Initializing...")
276
295
  return 42
277
-
296
+
278
297
  print(f"initialize() = {initialize()}")
279
298
  print(f"initialize() = {initialize()} (cached)")
280
-
299
+
281
300
  # 测试函数式编程工具
282
301
  print("\n=== 测试 Ops ===")
283
-
302
+
284
303
  result = range(10) | Ops.filter(lambda x: x % 2 == 0) | Ops.map(lambda x: x * 2) | Ops.sum()
285
304
  print(f"range(10) | filter(x % 2 == 0) | map(x * 2) | sum() = {result}")
286
-
305
+
287
306
  # 测试 Seq
288
307
  print("\n=== 测试 Seq ===")
289
-
308
+
290
309
  result = Seq(range(10)).map(lambda x: x * 2).filter(lambda x: x > 5).collect()
291
310
  print(f"Seq(range(10)).map(x * 2).filter(x > 5).collect() = {result}")
292
-
311
+
293
312
  # 测试 repeat
294
313
  print("\n=== 测试 repeat ===")
295
-
314
+
296
315
  @repeat(cnt=3, delay=0.1)
297
316
  def hello(name):
298
317
  return f"Hello, {name}!"
299
-
318
+
300
319
  for i, result in enumerate(hello("World")):
301
320
  print(f"调用 {i+1}: {result}")
302
-
321
+
303
322
  print("\n所有测试通过!")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vools
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: Python 函数式编程工具集
5
5
  Home-page: https://github.com/vicTop-cw/vools
6
6
  Author: Victor
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes