pymud 0.20.2a3__py3-none-any.whl → 0.20.2a5__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.
- pymud/extras.py +15 -11
- pymud/session.py +24 -22
- pymud/settings.py +3 -3
- {pymud-0.20.2a3.dist-info → pymud-0.20.2a5.dist-info}/METADATA +2 -1
- {pymud-0.20.2a3.dist-info → pymud-0.20.2a5.dist-info}/RECORD +9 -9
- {pymud-0.20.2a3.dist-info → pymud-0.20.2a5.dist-info}/LICENSE.txt +0 -0
- {pymud-0.20.2a3.dist-info → pymud-0.20.2a5.dist-info}/WHEEL +0 -0
- {pymud-0.20.2a3.dist-info → pymud-0.20.2a5.dist-info}/entry_points.txt +0 -0
- {pymud-0.20.2a3.dist-info → pymud-0.20.2a5.dist-info}/top_level.txt +0 -0
pymud/extras.py
CHANGED
@@ -66,8 +66,8 @@ class MudFormatProcessor(Processor):
|
|
66
66
|
self.FULL_BLOCKS = set("▂▃▅▆▇▄█")
|
67
67
|
self.SINGLE_LINES = set("┌└├┬┼┴╭╰─")
|
68
68
|
self.DOUBLE_LINES = set("╔╚╠╦╪╩═")
|
69
|
-
|
70
|
-
self.
|
69
|
+
self.ALL_COLOR_REGX = re.compile(r"(?:\[[\d;]+m)+")
|
70
|
+
self.AVAI_COLOR_REGX = re.compile(r"(?:\[[\d;]+m)+(?!$)")
|
71
71
|
self._color_start = ""
|
72
72
|
self._color_correction = False
|
73
73
|
self._color_line_index = 0
|
@@ -111,21 +111,25 @@ class MudFormatProcessor(Processor):
|
|
111
111
|
line = fragment_list_to_text(transformation_input.fragments)
|
112
112
|
|
113
113
|
# 颜色校正
|
114
|
-
thislinecolors = len(self.
|
114
|
+
thislinecolors = len(self.AVAI_COLOR_REGX.findall(line))
|
115
115
|
if thislinecolors == 0:
|
116
116
|
lineno = transformation_input.lineno - 1
|
117
117
|
while lineno > 0:
|
118
118
|
lastline = transformation_input.document.lines[lineno]
|
119
|
-
|
120
|
-
# if color:
|
121
|
-
colors = self.COLOR_REGX.findall(lastline)
|
119
|
+
allcolors = self.ALL_COLOR_REGX.findall(lastline)
|
122
120
|
|
123
|
-
if len(
|
124
|
-
lineno = lineno -1
|
121
|
+
if len(allcolors) == 0:
|
122
|
+
lineno = lineno - 1
|
125
123
|
|
126
|
-
elif len(
|
127
|
-
|
128
|
-
|
124
|
+
elif len(allcolors) == 1:
|
125
|
+
colors = self.AVAI_COLOR_REGX.findall(lastline)
|
126
|
+
|
127
|
+
if len(colors) == 1:
|
128
|
+
line = f"{colors[0]}{line}"
|
129
|
+
break
|
130
|
+
|
131
|
+
else:
|
132
|
+
break
|
129
133
|
|
130
134
|
else:
|
131
135
|
break
|
pymud/session.py
CHANGED
@@ -3012,15 +3012,15 @@ class Session:
|
|
3012
3012
|
triggered += 1
|
3013
3013
|
# info_enabled.append(f" {Settings.INFO_STYLE}{tri.__detailed__()} 正常触发。{Settings.CLR_STYLE}")
|
3014
3014
|
# info_enabled.append(f" {Settings.INFO_STYLE}捕获:{state.wildcards}{Settings.CLR_STYLE}")
|
3015
|
-
info_enabled.append(f"
|
3016
|
-
info_enabled.append(f"
|
3015
|
+
info_enabled.append(f" {tri.__detailed__()} 正常触发。")
|
3016
|
+
info_enabled.append(f" 捕获:{state.wildcards}")
|
3017
3017
|
|
3018
3018
|
if not tri.keepEval: # 非持续匹配的trigger,匹配成功后停止检测后续Trigger
|
3019
|
-
info_enabled.append(f"
|
3019
|
+
info_enabled.append(f" {Settings.WARN_STYLE}该触发器未开启keepEval, 会阻止后续触发器。{Settings.CLR_STYLE}")
|
3020
3020
|
#info_enabled.append(f" 该触发器未开启keepEval, 会阻止后续触发器。")
|
3021
3021
|
block = True
|
3022
3022
|
else:
|
3023
|
-
info_enabled.append(f"
|
3023
|
+
info_enabled.append(f" {Settings.WARN_STYLE}{tri.__detailed__()} 可以触发,但由于优先级与keepEval设定,触发器不会触发。{Settings.CLR_STYLE}")
|
3024
3024
|
#info_enabled.append(f" {tri.__detailed__()} 可以触发,但由于优先级与keepEval设定,触发器不会触发。")
|
3025
3025
|
|
3026
3026
|
|
@@ -3033,35 +3033,37 @@ class Session:
|
|
3033
3033
|
if state.result == Trigger.SUCCESS:
|
3034
3034
|
triggered_disabled += 1
|
3035
3035
|
# info_disabled.append(f" {Settings.INFO_STYLE}{tri.__detailed__()} 可以匹配触发。{Settings.CLR_STYLE}")
|
3036
|
-
info_disabled.append(f"
|
3036
|
+
info_disabled.append(f" {tri.__detailed__()} 可以匹配触发。")
|
3037
3037
|
|
3038
3038
|
if triggered_enabled + triggered_disabled == 0:
|
3039
3039
|
info_all.append("")
|
3040
3040
|
|
3041
3041
|
if triggered_enabled == 0:
|
3042
|
-
info_enabled.insert(0, f"{Settings.INFO_STYLE}使能的触发器中,没有可以触发的。")
|
3042
|
+
info_enabled.insert(0, f"{Settings.INFO_STYLE} 使能的触发器中,没有可以触发的。")
|
3043
3043
|
elif triggered < triggered_enabled:
|
3044
|
-
info_enabled.insert(0, f"{Settings.INFO_STYLE}使能的触发器中,共有 {triggered_enabled} 个可以触发,实际触发 {triggered} 个,另有 {triggered_enabled - triggered} 个由于 keepEval 原因实际不会触发。")
|
3044
|
+
info_enabled.insert(0, f"{Settings.INFO_STYLE} 使能的触发器中,共有 {triggered_enabled} 个可以触发,实际触发 {triggered} 个,另有 {triggered_enabled - triggered} 个由于 keepEval 原因实际不会触发。")
|
3045
3045
|
else:
|
3046
|
-
info_enabled.insert(0, f"{Settings.INFO_STYLE}使能的触发器中,共有 {triggered_enabled} 个全部可以被正常触发。")
|
3046
|
+
info_enabled.insert(0, f"{Settings.INFO_STYLE} 使能的触发器中,共有 {triggered_enabled} 个全部可以被正常触发。")
|
3047
3047
|
|
3048
3048
|
if triggered_disabled > 0:
|
3049
|
-
info_disabled.insert(0, f"{Settings.INFO_STYLE}未使能的触发器中,共有 {triggered_disabled} 个可以匹配。")
|
3049
|
+
info_disabled.insert(0, f"{Settings.INFO_STYLE} 未使能的触发器中,共有 {triggered_disabled} 个可以匹配。")
|
3050
3050
|
else:
|
3051
|
-
info_disabled.insert(0, f"{Settings.INFO_STYLE}未使能触发器,没有可以匹配的。")
|
3052
|
-
|
3051
|
+
info_disabled.insert(0, f"{Settings.INFO_STYLE} 未使能触发器,没有可以匹配的。")
|
3052
|
+
|
3053
|
+
info_all.append("")
|
3053
3054
|
if triggered_enabled + triggered_disabled == 0:
|
3054
|
-
info_all.append(f"PYMUD 触发器测试: {'响应模式' if docallback else '测试模式'}")
|
3055
|
+
#info_all.append(f"PYMUD 触发器测试: {'响应模式' if docallback else '测试模式'}")
|
3055
3056
|
info_all.append(f" 测试内容: {line}")
|
3056
3057
|
info_all.append(f" 测试结果: 没有可以匹配的触发器。")
|
3057
3058
|
else:
|
3058
|
-
info_all.append(f"PYMUD 触发器测试: {'响应模式' if docallback else '测试模式'}")
|
3059
|
+
#info_all.append(f"PYMUD 触发器测试: {'响应模式' if docallback else '测试模式'}")
|
3059
3060
|
info_all.append(f" 测试内容: {line}")
|
3060
3061
|
info_all.append(f" 测试结果: 有{triggered}个触发器可以被正常触发,一共有{triggered_enabled + triggered_disabled}个满足匹配触发要求。")
|
3061
3062
|
info_all.extend(info_enabled)
|
3062
3063
|
info_all.extend(info_disabled)
|
3063
|
-
|
3064
|
-
|
3064
|
+
|
3065
|
+
title = f"触发器测试 - {'响应模式' if docallback else '测试模式'}"
|
3066
|
+
self.info("\n".join(info_all), title)
|
3065
3067
|
#self.info("PYMUD 触发器测试 完毕")
|
3066
3068
|
|
3067
3069
|
def handle_plugins(self, code: CodeLine = None, *args, **kwargs):
|
@@ -3185,7 +3187,7 @@ class Session:
|
|
3185
3187
|
'''
|
3186
3188
|
|
3187
3189
|
new_text, new_code = code.expand(self, *args, **kwargs)
|
3188
|
-
self.warning(new_text[
|
3190
|
+
self.warning(new_text[9:])
|
3189
3191
|
|
3190
3192
|
def handle_error(self, code: CodeLine = None, *args, **kwargs):
|
3191
3193
|
'''
|
@@ -3201,9 +3203,9 @@ class Session:
|
|
3201
3203
|
'''
|
3202
3204
|
|
3203
3205
|
new_text, new_code = code.expand(self, *args, **kwargs)
|
3204
|
-
self.error(new_text[
|
3206
|
+
self.error(new_text[7:])
|
3205
3207
|
|
3206
|
-
def info2(self, msg, title = "
|
3208
|
+
def info2(self, msg, title = "消息", style = Settings.INFO_STYLE):
|
3207
3209
|
msg = f"{msg}"
|
3208
3210
|
|
3209
3211
|
# if Settings.client["newline"] in msg:
|
@@ -3215,9 +3217,9 @@ class Session:
|
|
3215
3217
|
# msg = Settings.client["newline"].join(new_lines)
|
3216
3218
|
|
3217
3219
|
# 将颜色跨行显示移动到了MudFormatProcessor中,此处无需再处理(不行,还得恢复)
|
3218
|
-
self.writetobuffer("{}
|
3220
|
+
self.writetobuffer("{}〔{}〕{}{}".format(style, title, msg, Settings.CLR_STYLE), newline = True)
|
3219
3221
|
|
3220
|
-
def info(self, msg, title = "
|
3222
|
+
def info(self, msg, title = "提示", style = Settings.INFO_STYLE):
|
3221
3223
|
"""
|
3222
3224
|
使用默认的INFO_STYLE(绿色)输出信息,并自动换行。信息格式类似 [title] msg
|
3223
3225
|
|
@@ -3227,7 +3229,7 @@ class Session:
|
|
3227
3229
|
"""
|
3228
3230
|
self.info2(msg, title, style)
|
3229
3231
|
|
3230
|
-
def warning(self, msg, title = "
|
3232
|
+
def warning(self, msg, title = "警告", style = Settings.WARN_STYLE):
|
3231
3233
|
"""
|
3232
3234
|
使用默认的WARN_STYLE(黄色)输出信息,并自动换行。信息格式类似 [title] msg
|
3233
3235
|
|
@@ -3237,7 +3239,7 @@ class Session:
|
|
3237
3239
|
"""
|
3238
3240
|
self.info2(msg, title, style)
|
3239
3241
|
|
3240
|
-
def error(self, msg, title = "
|
3242
|
+
def error(self, msg, title = "错误", style = Settings.ERR_STYLE):
|
3241
3243
|
"""
|
3242
3244
|
使用默认的ERR_STYLE(红色)输出信息,并自动换行。信息格式类似 [title] msg
|
3243
3245
|
|
pymud/settings.py
CHANGED
@@ -174,8 +174,8 @@ class Settings:
|
|
174
174
|
"value" : "fg:green",
|
175
175
|
}
|
176
176
|
|
177
|
-
INFO_STYLE = "\x1b[
|
178
|
-
WARN_STYLE = "\x1b[
|
179
|
-
ERR_STYLE = "\x1b[
|
177
|
+
INFO_STYLE = "\x1b[48;5;22m\x1b[38;5;252m" #"\x1b[38;2;0;128;255m"
|
178
|
+
WARN_STYLE = "\x1b[48;5;220m\x1b[38;5;238m"
|
179
|
+
ERR_STYLE = "\x1b[48;5;160m\x1b[38;5;252m"
|
180
180
|
CLR_STYLE = "\x1b[0m"
|
181
181
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pymud
|
3
|
-
Version: 0.20.
|
3
|
+
Version: 0.20.2a5
|
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>
|
@@ -742,6 +742,7 @@ Requires-Dist: prompt-toolkit
|
|
742
742
|
+ 功能调整: 修复了纯文本正则处理,目前理论上支持所有ANSI控制代码的处置,以正确响应纯文本触发器。
|
743
743
|
+ 功能调整: 修改了#var和#global的显示实现,提高了变量打印排列的整齐度和辨识度,以适应长值变量和复杂变量。
|
744
744
|
+ 问题修复: 修复了单行颜色代码跨行无法显示问题。现在星宿毒草可以正常辨认颜色了。
|
745
|
+
+ 功能调整: 调整了info/warning/error的显示处理,默认样式进行了修改。
|
745
746
|
|
746
747
|
## 0.20.1 (2024-11-16)
|
747
748
|
+ 功能调整: 会话中触发器匹配实现进行部分调整,减少循环次数以提高响应速度
|
@@ -1,7 +1,7 @@
|
|
1
1
|
pymud/__init__.py,sha256=AP4Edhx90gMKrNfD1O_KVciA3SOnyX5Qt9fZY_JhsTY,574
|
2
2
|
pymud/__main__.py,sha256=hFzZjadLlcOuoLM7D8wFiFVO8mqF7vMuo9y-9xfIhRc,64
|
3
3
|
pymud/dialogs.py,sha256=p-LidObSuDyOeMif5CsqhF5qq3rizZ1lmThWHrxDyRg,6726
|
4
|
-
pymud/extras.py,sha256=
|
4
|
+
pymud/extras.py,sha256=lCRlNIaYqrcCLGe8zrulFvh7aC5nU_jHFMD2sI9JCrU,40955
|
5
5
|
pymud/logger.py,sha256=sq9HhZ6-prY34NnDUO1NjaCRy-e5-fr2j0na8FKp9ks,5789
|
6
6
|
pymud/main.py,sha256=b_Ui_cN4W8IfhYNyc1duwr3Bp7pYYZQusKTSafCWZIA,6534
|
7
7
|
pymud/modules.py,sha256=XoqTeYfZCgqDsV3SYxeehzsbkTzs0swelAUIxyWuL9g,7423
|
@@ -9,11 +9,11 @@ pymud/objects.py,sha256=qSOFuVZvMh3lxjg6x5JUzcr_sTSgakWWySh801x7TNQ,39457
|
|
9
9
|
pymud/pkuxkx.py,sha256=jRQRUs2xtw7GzYHtLYZXOASnqMumKh0iCoOeKZs8NnU,11467
|
10
10
|
pymud/protocol.py,sha256=nlsyXMBAHEf_067mPNGDHzN_zIm9808D8YDIZTNrygg,49118
|
11
11
|
pymud/pymud.py,sha256=4v-pdSheWfWCK7O-3bAipK7WE6zPe8mRLil7E1Zbnas,51663
|
12
|
-
pymud/session.py,sha256=
|
13
|
-
pymud/settings.py,sha256=
|
14
|
-
pymud-0.20.
|
15
|
-
pymud-0.20.
|
16
|
-
pymud-0.20.
|
17
|
-
pymud-0.20.
|
18
|
-
pymud-0.20.
|
19
|
-
pymud-0.20.
|
12
|
+
pymud/session.py,sha256=dO6asU6Pva9JjuhecyUHDCp1qH59FkSIUsmJbTjtFDI,139001
|
13
|
+
pymud/settings.py,sha256=LHDomT7AMVUi1QQqlFS02mgQ6AqJJBkZeg8YoF-43SE,7204
|
14
|
+
pymud-0.20.2a5.dist-info/LICENSE.txt,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
|
15
|
+
pymud-0.20.2a5.dist-info/METADATA,sha256=8oYUsKU0Rwbys95Xc9esV2-5SfyV6VY7QVSTdP2fSZo,75041
|
16
|
+
pymud-0.20.2a5.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
17
|
+
pymud-0.20.2a5.dist-info/entry_points.txt,sha256=diPUOtTkhgC1hVny7Cdg4aRhaHSynMQoraE7ZhJxUcw,37
|
18
|
+
pymud-0.20.2a5.dist-info/top_level.txt,sha256=8Gp1eXjxixXjqhhti6tLCspV_8s9sNV3z5Em2_KRhD4,6
|
19
|
+
pymud-0.20.2a5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|