ErisPulse 2.3.3.dev0__py3-none-any.whl → 2.3.4.dev2__py3-none-any.whl

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 (97) hide show
  1. ErisPulse/CLI/__init__.py +11 -0
  2. ErisPulse/CLI/__init__.pyi +13 -0
  3. ErisPulse/CLI/base.py +52 -0
  4. ErisPulse/CLI/base.pyi +50 -0
  5. ErisPulse/CLI/cli.py +224 -0
  6. ErisPulse/CLI/cli.pyi +80 -0
  7. ErisPulse/CLI/commands/__init__.py +6 -0
  8. ErisPulse/CLI/commands/__init__.pyi +12 -0
  9. ErisPulse/CLI/commands/init.py +395 -0
  10. ErisPulse/CLI/commands/init.pyi +70 -0
  11. ErisPulse/CLI/commands/install.py +302 -0
  12. ErisPulse/CLI/commands/install.pyi +58 -0
  13. ErisPulse/CLI/commands/list.py +160 -0
  14. ErisPulse/CLI/commands/list.pyi +44 -0
  15. ErisPulse/CLI/commands/list_remote.py +123 -0
  16. ErisPulse/CLI/commands/list_remote.pyi +35 -0
  17. ErisPulse/CLI/commands/run.py +108 -0
  18. ErisPulse/CLI/commands/run.pyi +39 -0
  19. ErisPulse/CLI/commands/self_update.py +232 -0
  20. ErisPulse/CLI/commands/self_update.pyi +47 -0
  21. ErisPulse/CLI/commands/uninstall.py +32 -0
  22. ErisPulse/CLI/commands/uninstall.pyi +24 -0
  23. ErisPulse/CLI/commands/upgrade.py +56 -0
  24. ErisPulse/CLI/commands/upgrade.pyi +25 -0
  25. ErisPulse/CLI/console.pyi +20 -0
  26. ErisPulse/CLI/registry.py +112 -0
  27. ErisPulse/CLI/registry.pyi +99 -0
  28. ErisPulse/{utils → CLI/utils}/__init__.py +2 -6
  29. ErisPulse/CLI/utils/__init__.pyi +14 -0
  30. ErisPulse/{utils → CLI/utils}/package_manager.py +146 -20
  31. ErisPulse/CLI/utils/package_manager.pyi +241 -0
  32. ErisPulse/{utils → CLI/utils}/reload_handler.py +7 -8
  33. ErisPulse/CLI/utils/reload_handler.pyi +64 -0
  34. ErisPulse/Core/Bases/__init__.pyi +14 -0
  35. ErisPulse/Core/Bases/adapter.py +13 -1
  36. ErisPulse/Core/Bases/adapter.pyi +140 -0
  37. ErisPulse/Core/Bases/manager.py +136 -0
  38. ErisPulse/Core/Bases/manager.pyi +108 -0
  39. ErisPulse/Core/Bases/module.py +53 -1
  40. ErisPulse/Core/Bases/module.pyi +95 -0
  41. ErisPulse/Core/Event/__init__.pyi +26 -0
  42. ErisPulse/Core/Event/base.pyi +62 -0
  43. ErisPulse/Core/Event/command.py +6 -1
  44. ErisPulse/Core/Event/command.pyi +113 -0
  45. ErisPulse/Core/Event/exceptions.pyi +43 -0
  46. ErisPulse/Core/Event/message.pyi +93 -0
  47. ErisPulse/Core/Event/meta.pyi +92 -0
  48. ErisPulse/Core/Event/notice.pyi +108 -0
  49. ErisPulse/Core/Event/request.pyi +76 -0
  50. ErisPulse/Core/Event/wrapper.py +2 -3
  51. ErisPulse/Core/Event/wrapper.pyi +403 -0
  52. ErisPulse/Core/__init__.py +16 -13
  53. ErisPulse/Core/__init__.pyi +16 -0
  54. ErisPulse/Core/_self_config.py +1 -1
  55. ErisPulse/Core/_self_config.pyi +72 -0
  56. ErisPulse/Core/adapter.py +70 -10
  57. ErisPulse/Core/adapter.pyi +246 -0
  58. ErisPulse/Core/config.pyi +70 -0
  59. ErisPulse/Core/exceptions.py +4 -2
  60. ErisPulse/Core/exceptions.pyi +60 -0
  61. ErisPulse/Core/lifecycle.py +15 -1
  62. ErisPulse/Core/lifecycle.pyi +92 -0
  63. ErisPulse/Core/logger.py +21 -15
  64. ErisPulse/Core/logger.pyi +169 -0
  65. ErisPulse/Core/module.py +57 -9
  66. ErisPulse/Core/module.pyi +189 -0
  67. ErisPulse/Core/router.py +13 -5
  68. ErisPulse/Core/router.pyi +120 -0
  69. ErisPulse/Core/storage.py +94 -256
  70. ErisPulse/Core/storage.pyi +220 -0
  71. ErisPulse/__init__.py +35 -1236
  72. ErisPulse/__init__.pyi +22 -0
  73. ErisPulse/__main__.py +1 -1
  74. ErisPulse/__main__.pyi +24 -0
  75. ErisPulse/loaders/__init__.py +22 -0
  76. ErisPulse/loaders/__init__.pyi +21 -0
  77. ErisPulse/loaders/adapter_loader.py +187 -0
  78. ErisPulse/loaders/adapter_loader.pyi +82 -0
  79. ErisPulse/loaders/base_loader.py +162 -0
  80. ErisPulse/loaders/base_loader.pyi +23 -0
  81. ErisPulse/loaders/initializer.py +150 -0
  82. ErisPulse/loaders/initializer.pyi +60 -0
  83. ErisPulse/loaders/module_loader.py +618 -0
  84. ErisPulse/loaders/module_loader.pyi +179 -0
  85. ErisPulse/loaders/strategy.py +129 -0
  86. ErisPulse/loaders/strategy.pyi +90 -0
  87. ErisPulse/sdk.py +435 -0
  88. ErisPulse/sdk.pyi +158 -0
  89. {erispulse-2.3.3.dev0.dist-info → erispulse-2.3.4.dev2.dist-info}/METADATA +6 -20
  90. erispulse-2.3.4.dev2.dist-info/RECORD +103 -0
  91. {erispulse-2.3.3.dev0.dist-info → erispulse-2.3.4.dev2.dist-info}/licenses/LICENSE +3 -3
  92. ErisPulse/Core/ux.py +0 -635
  93. ErisPulse/utils/cli.py +0 -1097
  94. erispulse-2.3.3.dev0.dist-info/RECORD +0 -35
  95. /ErisPulse/{utils → CLI}/console.py +0 -0
  96. {erispulse-2.3.3.dev0.dist-info → erispulse-2.3.4.dev2.dist-info}/WHEEL +0 -0
  97. {erispulse-2.3.3.dev0.dist-info → erispulse-2.3.4.dev2.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,11 @@
1
+ """
2
+ CLI 模块
3
+
4
+ ErisPulse 命令行接口
5
+ """
6
+
7
+ from .cli import CLI
8
+
9
+ __all__ = [
10
+ "CLI",
11
+ ]
@@ -0,0 +1,13 @@
1
+ # type: ignore
2
+ #
3
+ # Auto-generated type stub for __init__.py
4
+ # DO NOT EDIT MANUALLY - Generated by generate-type-stubs.py
5
+ #
6
+
7
+ """
8
+ CLI 模块
9
+
10
+ ErisPulse 命令行接口
11
+ """
12
+
13
+ from .cli import CLI
ErisPulse/CLI/base.py ADDED
@@ -0,0 +1,52 @@
1
+ """
2
+ CLI 命令基类
3
+
4
+ 定义所有命令的统一接口
5
+ """
6
+
7
+ from abc import ABC, abstractmethod
8
+ from argparse import ArgumentParser
9
+
10
+
11
+ class Command(ABC):
12
+ """
13
+ 命令基类
14
+
15
+ 所有 CLI 命令都应继承此类并实现抽象方法
16
+
17
+ {!--< tips >!--}
18
+ 1. 每个命令类必须实现 add_arguments 和 execute 方法
19
+ 2. name 和 description 为类属性,必须在子类中定义
20
+ 3. execute 方法接收解析后的 args 对象
21
+ {!--< /tips >!--}
22
+ """
23
+
24
+ name: str = "" # 命令名称
25
+ description: str = "" # 命令描述
26
+
27
+ @abstractmethod
28
+ def add_arguments(self, parser: ArgumentParser):
29
+ """
30
+ 添加命令参数
31
+
32
+ :param parser: ArgumentParser 实例
33
+ """
34
+ pass
35
+
36
+ @abstractmethod
37
+ def execute(self, args):
38
+ """
39
+ 执行命令
40
+
41
+ :param args: 解析后的参数对象
42
+ """
43
+ pass
44
+
45
+ @property
46
+ def help(self) -> str:
47
+ """
48
+ 获取帮助信息
49
+
50
+ :return: 命令描述
51
+ """
52
+ return self.description
ErisPulse/CLI/base.pyi ADDED
@@ -0,0 +1,50 @@
1
+ # type: ignore
2
+ #
3
+ # Auto-generated type stub for base.py
4
+ # DO NOT EDIT MANUALLY - Generated by generate-type-stubs.py
5
+ #
6
+
7
+ """
8
+ CLI 命令基类
9
+
10
+ 定义所有命令的统一接口
11
+ """
12
+
13
+ from abc import ABC, abstractmethod
14
+ from argparse import ArgumentParser
15
+
16
+ class Command(ABC):
17
+ """
18
+ 命令基类
19
+
20
+ 所有 CLI 命令都应继承此类并实现抽象方法
21
+
22
+ {!--< tips >!--}
23
+ 1. 每个命令类必须实现 add_arguments 和 execute 方法
24
+ 2. name 和 description 为类属性,必须在子类中定义
25
+ 3. execute 方法接收解析后的 args 对象
26
+ {!--< /tips >!--}
27
+ """
28
+ name: str
29
+ description: str
30
+ def add_arguments(self: object, parser: ArgumentParser) -> ...:
31
+ """
32
+ 添加命令参数
33
+
34
+ :param parser: ArgumentParser 实例
35
+ """
36
+ ...
37
+ def execute(self: object, args: ...) -> ...:
38
+ """
39
+ 执行命令
40
+
41
+ :param args: 解析后的参数对象
42
+ """
43
+ ...
44
+ def help(self: object) -> str:
45
+ """
46
+ 获取帮助信息
47
+
48
+ :return: 命令描述
49
+ """
50
+ ...
ErisPulse/CLI/cli.py ADDED
@@ -0,0 +1,224 @@
1
+ """
2
+ 主 CLI 类
3
+
4
+ ErisPulse 命令行接口主入口
5
+ """
6
+
7
+ import sys
8
+ import importlib
9
+ import importlib.metadata
10
+ import asyncio
11
+ import traceback
12
+ import pkgutil
13
+ from argparse import ArgumentParser, RawDescriptionHelpFormatter
14
+
15
+ from rich.panel import Panel
16
+
17
+ from .console import console
18
+ from .registry import CommandRegistry
19
+ from .base import Command
20
+
21
+
22
+ class CLI:
23
+ """
24
+ ErisPulse 命令行接口主类
25
+
26
+ 提供完整的命令行交互功能,支持动态加载第三方命令
27
+ """
28
+
29
+ def __init__(self):
30
+ """初始化 CLI"""
31
+ self.registry = CommandRegistry()
32
+ self.parser = self._create_parser()
33
+ self._register_builtin_commands()
34
+ self._load_external_commands()
35
+
36
+ def _create_parser(self) -> ArgumentParser:
37
+ """
38
+ 创建命令行参数解析器
39
+
40
+ :return: 配置好的 ArgumentParser 实例
41
+ """
42
+ parser = ArgumentParser(
43
+ prog="epsdk",
44
+ formatter_class=RawDescriptionHelpFormatter,
45
+ description="ErisPulse SDK 命令行工具",
46
+ )
47
+ parser._positionals.title = "命令"
48
+ parser._optionals.title = "选项"
49
+
50
+ # 全局选项
51
+ parser.add_argument(
52
+ "--version", "-V",
53
+ action="store_true",
54
+ help="显示版本信息"
55
+ )
56
+ parser.add_argument(
57
+ "--verbose", "-v",
58
+ action="count",
59
+ default=0,
60
+ help="增加输出详细程度 (-v, -vv, -vvv)"
61
+ )
62
+
63
+ # 子命令
64
+ subparsers = parser.add_subparsers(
65
+ dest='command',
66
+ metavar="<命令>",
67
+ help="要执行的操作"
68
+ )
69
+
70
+ self.subparsers = subparsers
71
+ return parser
72
+
73
+ def _auto_discover_commands(self):
74
+ """
75
+ 自动发现并注册 commands 目录中的所有命令
76
+
77
+ 动态扫描 commands 目录,查找所有继承自 Command 基类的命令类
78
+ 并自动注册到命令注册表中。
79
+ """
80
+ # 获取 commands 包的路径
81
+ commands_package = 'ErisPulse.CLI.commands'
82
+
83
+ try:
84
+ # 遍历 commands 包中的所有模块
85
+ for importer, module_name, ispkg in pkgutil.iter_modules(
86
+ importlib.import_module(commands_package).__path__,
87
+ prefix=f"{commands_package}."
88
+ ):
89
+ # 跳过 __init__ 和 __pycache__ 目录
90
+ if module_name.endswith('.__init__') or '__pycache__' in module_name:
91
+ continue
92
+
93
+ try:
94
+ # 动态导入模块
95
+ module = importlib.import_module(module_name)
96
+
97
+ # 查找模块中所有继承自 Command 的类
98
+ for attr_name in dir(module):
99
+ attr = getattr(module, attr_name)
100
+
101
+ # 检查是否是 Command 的子类(排除 Command 基类本身)
102
+ if (isinstance(attr, type) and
103
+ issubclass(attr, Command) and
104
+ attr is not Command):
105
+ try:
106
+ # 实例化并注册命令
107
+ command_instance = attr()
108
+ self.registry.register(command_instance)
109
+ except Exception as e:
110
+ console.print(f"[warning]实例化命令 {attr_name} 失败: {e}[/]")
111
+
112
+ except Exception as e:
113
+ console.print(f"[warning]加载命令模块 {module_name} 失败: {e}[/]")
114
+
115
+ except ImportError as e:
116
+ console.print(f"[warning]无法导入 commands 包: {e}[/]")
117
+
118
+ def _register_builtin_commands(self):
119
+ """注册所有内置命令(通过自动发现)"""
120
+ self._auto_discover_commands()
121
+
122
+ # 添加所有命令的参数
123
+ for command in self.registry.get_all():
124
+ parser = self.subparsers.add_parser(
125
+ command.name,
126
+ help=command.description
127
+ )
128
+ command.add_arguments(parser)
129
+
130
+ def _load_external_commands(self):
131
+ """
132
+ 加载第三方 CLI 命令
133
+ """
134
+ try:
135
+ entry_points = importlib.metadata.entry_points()
136
+ if hasattr(entry_points, 'select'):
137
+ cli_entries = entry_points.select(group='erispulse.cli')
138
+ else:
139
+ cli_entries = entry_points.get('erispulse.cli', [])
140
+
141
+ for entry in cli_entries:
142
+ try:
143
+ cli_func = entry.load()
144
+ if callable(cli_func):
145
+ # 传入 subparsers 和 console,保持兼容性
146
+ cli_func(self.subparsers, console)
147
+ else:
148
+ console.print(f"[warning]模块 {entry.name} 的入口点不是可调用对象[/]")
149
+ except Exception as e:
150
+ console.print(f"[error]加载第三方命令 {entry.name} 失败: {e}[/]")
151
+ except Exception as e:
152
+ console.print(f"[warning]加载第三方CLI命令失败: {e}[/]")
153
+
154
+ def _print_version(self):
155
+ """打印版本信息"""
156
+ from ErisPulse import __version__
157
+ console.print(Panel(
158
+ f"[title]ErisPulse SDK[/] 版本: [bold]{__version__}[/]",
159
+ subtitle=f"Python {sys.version.split()[0]}",
160
+ style="title"
161
+ ))
162
+
163
+ def run(self):
164
+ """
165
+ 运行 CLI
166
+
167
+ :raises KeyboardInterrupt: 用户中断时抛出
168
+ :raises Exception: 命令执行失败时抛出
169
+ """
170
+ args = self.parser.parse_args()
171
+
172
+ # 处理版本选项
173
+ if args.version:
174
+ self._print_version()
175
+ return
176
+
177
+ # 没有指定命令时显示帮助
178
+ if not args.command:
179
+ self.parser.print_help()
180
+ return
181
+
182
+ try:
183
+ # 执行命令
184
+ command = self.registry.get(args.command)
185
+ if command:
186
+ command.execute(args)
187
+ else:
188
+ # 第三方命令处理
189
+ self._execute_external_command(args)
190
+
191
+ except KeyboardInterrupt:
192
+ console.print("\n[warning]操作被用户中断[/]")
193
+ sys.exit(1)
194
+ except Exception as e:
195
+ console.print(f"[error]执行命令时出错: {e}[/]")
196
+ if args.verbose >= 1:
197
+ console.print(traceback.format_exc())
198
+ sys.exit(1)
199
+
200
+ def _execute_external_command(self, args):
201
+ """
202
+ 执行第三方命令
203
+
204
+ :param args: 解析后的参数
205
+ """
206
+ try:
207
+ # 第三方命令在注册时已经通过 set_defaults(func=handle_command) 设置了处理函数
208
+ # 所以 args.func 就是处理函数
209
+ if hasattr(args, 'func') and args.func:
210
+ handler_func = args.func
211
+ if asyncio.iscoroutinefunction(handler_func):
212
+ # 异步函数:使用 asyncio.run() 运行
213
+ asyncio.run(handler_func(args))
214
+ else:
215
+ # 同步函数:直接调用
216
+ handler_func(args)
217
+ else:
218
+ console.print(f"[error]命令 {args.command} 没有处理函数[/]")
219
+ sys.exit(1)
220
+ except Exception as e:
221
+ console.print(f"[error]执行第三方命令失败: {e}[/]")
222
+ if args.verbose >= 1:
223
+ console.print(traceback.format_exc())
224
+ sys.exit(1)
ErisPulse/CLI/cli.pyi ADDED
@@ -0,0 +1,80 @@
1
+ # type: ignore
2
+ #
3
+ # Auto-generated type stub for cli.py
4
+ # DO NOT EDIT MANUALLY - Generated by generate-type-stubs.py
5
+ #
6
+
7
+ """
8
+ 主 CLI 类
9
+
10
+ ErisPulse 命令行接口主入口
11
+ """
12
+
13
+ import sys
14
+ import importlib
15
+ import importlib.metadata
16
+ import asyncio
17
+ import traceback
18
+ import pkgutil
19
+ from argparse import ArgumentParser, RawDescriptionHelpFormatter
20
+ from rich.panel import Panel
21
+ from .console import console
22
+ from .registry import CommandRegistry
23
+ from .base import Command
24
+
25
+ class CLI:
26
+ """
27
+ ErisPulse 命令行接口主类
28
+
29
+ 提供完整的命令行交互功能,支持动态加载第三方命令
30
+ """
31
+ def __init__(self: None) -> ...:
32
+ """
33
+ 初始化 CLI
34
+ """
35
+ ...
36
+ def _create_parser(self: object) -> ArgumentParser:
37
+ """
38
+ 创建命令行参数解析器
39
+
40
+ :return: 配置好的 ArgumentParser 实例
41
+ """
42
+ ...
43
+ def _auto_discover_commands(self: object) -> ...:
44
+ """
45
+ 自动发现并注册 commands 目录中的所有命令
46
+
47
+ 动态扫描 commands 目录,查找所有继承自 Command 基类的命令类
48
+ 并自动注册到命令注册表中。
49
+ """
50
+ ...
51
+ def _register_builtin_commands(self: object) -> ...:
52
+ """
53
+ 注册所有内置命令(通过自动发现)
54
+ """
55
+ ...
56
+ def _load_external_commands(self: object) -> ...:
57
+ """
58
+ 加载第三方 CLI 命令
59
+ """
60
+ ...
61
+ def _print_version(self: object) -> ...:
62
+ """
63
+ 打印版本信息
64
+ """
65
+ ...
66
+ def run(self: object) -> ...:
67
+ """
68
+ 运行 CLI
69
+
70
+ :raises KeyboardInterrupt: 用户中断时抛出
71
+ :raises Exception: 命令执行失败时抛出
72
+ """
73
+ ...
74
+ def _execute_external_command(self: object, args: ...) -> ...:
75
+ """
76
+ 执行第三方命令
77
+
78
+ :param args: 解析后的参数
79
+ """
80
+ ...
@@ -0,0 +1,6 @@
1
+ """
2
+ 命令模块
3
+
4
+ 自动发现 commands 目录中的所有 CLI 命令。
5
+ 所有继承自 Command 基类的命令类都会被自动加载和注册。
6
+ """
@@ -0,0 +1,12 @@
1
+ # type: ignore
2
+ #
3
+ # Auto-generated type stub for __init__.py
4
+ # DO NOT EDIT MANUALLY - Generated by generate-type-stubs.py
5
+ #
6
+
7
+ """
8
+ 命令模块
9
+
10
+ 自动发现 commands 目录中的所有 CLI 命令。
11
+ 所有继承自 Command 基类的命令类都会被自动加载和注册。
12
+ """