pymud 0.21.0a2__tar.gz → 0.21.0a3__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.
- {pymud-0.21.0a2 → pymud-0.21.0a3}/PKG-INFO +2 -1
- {pymud-0.21.0a2 → pymud-0.21.0a3}/README.md +1 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/pyproject.toml +1 -1
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud/__init__.py +3 -2
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud/modules.py +5 -5
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud/session.py +33 -4
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud/settings.py +4 -2
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud.egg-info/PKG-INFO +2 -1
- {pymud-0.21.0a2 → pymud-0.21.0a3}/LICENSE.txt +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/setup.cfg +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud/__main__.py +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud/dialogs.py +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud/extras.py +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud/i18n.py +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud/lang/i18n_chs.py +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud/lang/i18n_eng.py +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud/logger.py +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud/main.py +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud/objects.py +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud/pkuxkx.py +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud/protocol.py +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud/pymud.py +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud.egg-info/SOURCES.txt +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud.egg-info/dependency_links.txt +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud.egg-info/entry_points.txt +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud.egg-info/requires.txt +0 -0
- {pymud-0.21.0a2 → pymud-0.21.0a3}/src/pymud.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pymud
|
3
|
-
Version: 0.21.
|
3
|
+
Version: 0.21.0a3
|
4
4
|
Summary: a MUD Client written in Python
|
5
5
|
Author-email: "newstart@pkuxkx" <crapex@hotmail.com>
|
6
6
|
Maintainer-email: "newstart@pkuxkx" <crapex@hotmail.com>
|
@@ -66,6 +66,7 @@ Dynamic: license-file
|
|
66
66
|
### 0.21.0a2 (2025-05-17)
|
67
67
|
+ 功能新增: 增加了国际化(i18n)支持,支持中文简体和英文。目前完全支持的仅中文简体,英文只完成了界面翻译,运行时的#help帮助内容暂未翻译。
|
68
68
|
+ 功能新增: 新增了使用元类型及装饰器来管理Pymud对象,包括Alias, Trigger, Timer, GMCPTrigger四种可以使用对应的装饰器,@alias, @trigger, @timer, @gmcp来直接在标记函数上创建。可以参考本版本中的pkuxkx.py文件写法
|
69
|
+
+ 功能新增: 新增了两个装饰器,@exception和@async_exception,用于捕获异常并调用session.error进行显示。@exception用于捕获同步异常,@async_exception用于捕获异步异常。
|
69
70
|
+ 问题修复: 之前对Alias和Command未进行优先级判断,因此遇到能同时匹配的多个时,不一定优先级高的被触发。现在对Alias和Command进行了优先级判断,优先级高的先触发。
|
70
71
|
+ 问题修复: 之前的Alias中的keepEval参数和oneShot参数不起作用,已修复。keepEval参数支持多个匹配成功的别名同时生效,oneShot参数支持一个匹配成功的别名生效后,后续的匹配不再生效。
|
71
72
|
+ 问题修复: 修复a1版中@alias别名创建错误的问题(a1版问题,a2版中已修复)
|
@@ -34,6 +34,7 @@
|
|
34
34
|
### 0.21.0a2 (2025-05-17)
|
35
35
|
+ 功能新增: 增加了国际化(i18n)支持,支持中文简体和英文。目前完全支持的仅中文简体,英文只完成了界面翻译,运行时的#help帮助内容暂未翻译。
|
36
36
|
+ 功能新增: 新增了使用元类型及装饰器来管理Pymud对象,包括Alias, Trigger, Timer, GMCPTrigger四种可以使用对应的装饰器,@alias, @trigger, @timer, @gmcp来直接在标记函数上创建。可以参考本版本中的pkuxkx.py文件写法
|
37
|
+
+ 功能新增: 新增了两个装饰器,@exception和@async_exception,用于捕获异常并调用session.error进行显示。@exception用于捕获同步异常,@async_exception用于捕获异步异常。
|
37
38
|
+ 问题修复: 之前对Alias和Command未进行优先级判断,因此遇到能同时匹配的多个时,不一定优先级高的被触发。现在对Alias和Command进行了优先级判断,优先级高的先触发。
|
38
39
|
+ 问题修复: 之前的Alias中的keepEval参数和oneShot参数不起作用,已修复。keepEval参数支持多个匹配成功的别名同时生效,oneShot参数支持一个匹配成功的别名生效后,后续的匹配不再生效。
|
39
40
|
+ 问题修复: 修复a1版中@alias别名创建错误的问题(a1版问题,a2版中已修复)
|
@@ -3,7 +3,7 @@ from .pymud import PyMudApp
|
|
3
3
|
from .modules import IConfig, PymudDecorator, PymudMeta, alias, trigger, timer, gmcp
|
4
4
|
from .objects import CodeBlock, Alias, SimpleAlias, Trigger, SimpleTrigger, Command, SimpleCommand, Timer, SimpleTimer, GMCPTrigger
|
5
5
|
from .extras import DotDict
|
6
|
-
from .session import Session
|
6
|
+
from .session import Session, exception, async_exception
|
7
7
|
from .logger import Logger
|
8
8
|
from .main import main
|
9
9
|
|
@@ -12,5 +12,6 @@ __all__ = [
|
|
12
12
|
"IConfig", "PyMudApp", "Settings", "CodeBlock",
|
13
13
|
"Alias", "SimpleAlias", "Trigger", "SimpleTrigger",
|
14
14
|
"Command", "SimpleCommand", "Timer", "SimpleTimer",
|
15
|
-
"GMCPTrigger", "Session", "DotDict", "Logger", "main"
|
15
|
+
"GMCPTrigger", "Session", "DotDict", "Logger", "main",
|
16
|
+
"exception", "async_exception"
|
16
17
|
]
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
import importlib, importlib.util
|
2
|
+
import importlib, importlib.util, functools
|
3
3
|
from abc import ABC, ABCMeta
|
4
4
|
from typing import Any, Annotated, Optional, Union
|
5
5
|
from .objects import BaseObject, Command, Trigger, Alias, Timer, GMCPTrigger
|
@@ -304,13 +304,13 @@ class IConfig(metaclass = PymudMeta):
|
|
304
304
|
for deco in decorators:
|
305
305
|
if isinstance(deco, PymudDecorator):
|
306
306
|
if deco.type == "alias":
|
307
|
-
patterns = deco.kwargs.pop("patterns")
|
308
|
-
ali = Alias(self.session,
|
307
|
+
#patterns = deco.kwargs.pop("patterns")
|
308
|
+
ali = Alias(self.session, *deco.args, **deco.kwargs, onSuccess = func)
|
309
309
|
self.__inline_objects__[ali.id] = ali
|
310
310
|
|
311
311
|
elif deco.type == "trigger":
|
312
|
-
patterns = deco.kwargs.pop("patterns")
|
313
|
-
tri = Trigger(self.session,
|
312
|
+
#patterns = deco.kwargs.pop("patterns")
|
313
|
+
tri = Trigger(self.session, *deco.args, **deco.kwargs, onSuccess = func)
|
314
314
|
self.__inline_objects__[tri.id] = tri
|
315
315
|
|
316
316
|
elif deco.type == "timer":
|
@@ -1,9 +1,7 @@
|
|
1
|
-
import asyncio, logging, re, math, os, pickle, datetime,
|
1
|
+
import asyncio, logging, re, math, os, pickle, datetime, sysconfig, time, dataclasses, functools, traceback
|
2
2
|
from collections.abc import Iterable
|
3
3
|
from collections import OrderedDict
|
4
|
-
import logging
|
5
|
-
from logging import FileHandler
|
6
|
-
from logging.handlers import QueueHandler, QueueListener
|
4
|
+
import logging
|
7
5
|
from wcwidth import wcswidth, wcwidth
|
8
6
|
from typing import Union, Optional, Annotated, Any
|
9
7
|
from .logger import Logger
|
@@ -3361,3 +3359,34 @@ class Session:
|
|
3361
3359
|
else:
|
3362
3360
|
self.application.show_logSelectDialog()
|
3363
3361
|
|
3362
|
+
|
3363
|
+
def exception(func):
|
3364
|
+
"""方法异常处理装饰器,捕获异常后通过会话的session.error打印相关信息"""
|
3365
|
+
@functools.wraps(func)
|
3366
|
+
def wrapper(self, *args, **kwargs):
|
3367
|
+
try:
|
3368
|
+
return func(self, *args, **kwargs)
|
3369
|
+
except Exception as e:
|
3370
|
+
# 调用类的错误处理方法
|
3371
|
+
session = getattr(self, "session", None)
|
3372
|
+
if isinstance(session, Session):
|
3373
|
+
session.error(f"函数执行中遇到异常, {e}, 类型为 {type(e)}")
|
3374
|
+
session.error(f"异常追踪为: {traceback.format_exc()}")
|
3375
|
+
else:
|
3376
|
+
raise # 当没有会话时,选择重新抛出异常
|
3377
|
+
return wrapper
|
3378
|
+
|
3379
|
+
def async_exception(func):
|
3380
|
+
"""异步方法异常处理装饰器,捕获异常后通过会话的session.error打印相关信息"""
|
3381
|
+
@functools.wraps(func)
|
3382
|
+
async def wrapper(self, *args, **kwargs):
|
3383
|
+
try:
|
3384
|
+
return await func(self, *args, **kwargs)
|
3385
|
+
except Exception as e:
|
3386
|
+
session = getattr(self, "session", None)
|
3387
|
+
if isinstance(session, Session):
|
3388
|
+
session.error(f"异步执行中遇到异常, {e}, 类型为 {type(e)}")
|
3389
|
+
session.error(f"异常追踪为: {traceback.format_exc()}")
|
3390
|
+
else:
|
3391
|
+
raise # 当没有会话时,选择重新抛出异常
|
3392
|
+
return wrapper
|
@@ -3,6 +3,8 @@ PyMUD Settings 文件
|
|
3
3
|
用于保存与App有关的各类配置、常量等
|
4
4
|
"""
|
5
5
|
|
6
|
+
import importlib.metadata
|
7
|
+
|
6
8
|
class Settings:
|
7
9
|
"保存PyMUD配置的全局对象"
|
8
10
|
|
@@ -11,9 +13,9 @@ class Settings:
|
|
11
13
|
"APP 名称, 默认PYMUD"
|
12
14
|
__appdesc__ = "a MUD client written in Python"
|
13
15
|
"APP 简要描述"
|
14
|
-
__version__ =
|
16
|
+
__version__ = importlib.metadata.version("pymud")
|
15
17
|
"APP 当前版本"
|
16
|
-
__release__ = "2025-05-
|
18
|
+
__release__ = "2025-05-17"
|
17
19
|
"APP 当前版本发布日期"
|
18
20
|
__author__ = "本牛(newstart)@北侠"
|
19
21
|
"APP 作者"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pymud
|
3
|
-
Version: 0.21.
|
3
|
+
Version: 0.21.0a3
|
4
4
|
Summary: a MUD Client written in Python
|
5
5
|
Author-email: "newstart@pkuxkx" <crapex@hotmail.com>
|
6
6
|
Maintainer-email: "newstart@pkuxkx" <crapex@hotmail.com>
|
@@ -66,6 +66,7 @@ Dynamic: license-file
|
|
66
66
|
### 0.21.0a2 (2025-05-17)
|
67
67
|
+ 功能新增: 增加了国际化(i18n)支持,支持中文简体和英文。目前完全支持的仅中文简体,英文只完成了界面翻译,运行时的#help帮助内容暂未翻译。
|
68
68
|
+ 功能新增: 新增了使用元类型及装饰器来管理Pymud对象,包括Alias, Trigger, Timer, GMCPTrigger四种可以使用对应的装饰器,@alias, @trigger, @timer, @gmcp来直接在标记函数上创建。可以参考本版本中的pkuxkx.py文件写法
|
69
|
+
+ 功能新增: 新增了两个装饰器,@exception和@async_exception,用于捕获异常并调用session.error进行显示。@exception用于捕获同步异常,@async_exception用于捕获异步异常。
|
69
70
|
+ 问题修复: 之前对Alias和Command未进行优先级判断,因此遇到能同时匹配的多个时,不一定优先级高的被触发。现在对Alias和Command进行了优先级判断,优先级高的先触发。
|
70
71
|
+ 问题修复: 之前的Alias中的keepEval参数和oneShot参数不起作用,已修复。keepEval参数支持多个匹配成功的别名同时生效,oneShot参数支持一个匹配成功的别名生效后,后续的匹配不再生效。
|
71
72
|
+ 问题修复: 修复a1版中@alias别名创建错误的问题(a1版问题,a2版中已修复)
|
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
|