pymud 0.19.3__py3-none-any.whl → 0.19.3.post2__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/__init__.py +0 -1
- pymud/extras.py +59 -51
- pymud/objects.py +231 -44
- pymud/protocol.py +4 -4
- pymud/pymud.py +101 -28
- pymud/session.py +662 -92
- pymud/settings.py +1 -1
- {pymud-0.19.3.dist-info → pymud-0.19.3.post2.dist-info}/LICENSE.txt +674 -674
- {pymud-0.19.3.dist-info → pymud-0.19.3.post2.dist-info}/METADATA +10 -2
- pymud-0.19.3.post2.dist-info/RECORD +16 -0
- pymud-0.19.3.dist-info/RECORD +0 -16
- {pymud-0.19.3.dist-info → pymud-0.19.3.post2.dist-info}/WHEEL +0 -0
- {pymud-0.19.3.dist-info → pymud-0.19.3.post2.dist-info}/entry_points.txt +0 -0
- {pymud-0.19.3.dist-info → pymud-0.19.3.post2.dist-info}/top_level.txt +0 -0
pymud/__init__.py
CHANGED
@@ -2,7 +2,6 @@ from .settings import Settings
|
|
2
2
|
from .objects import CodeBlock, Alias, SimpleAlias, Trigger, SimpleTrigger, Command, SimpleCommand, Timer, SimpleTimer, GMCPTrigger
|
3
3
|
from .extras import DotDict
|
4
4
|
from .session import Session
|
5
|
-
from .pymud import PyMudApp
|
6
5
|
|
7
6
|
__all__ = [
|
8
7
|
"Settings", "CodeBlock", "Alias", "SimpleAlias", "Trigger", "SimpleTrigger", "Command", "SimpleCommand", "Timer", "SimpleTimer", "GMCPTrigger", "Session", "PyMudApp", "DotDict"
|
pymud/extras.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# External Libraries
|
2
2
|
from unicodedata import east_asian_width
|
3
3
|
from wcwidth import wcwidth
|
4
|
-
from typing import
|
4
|
+
from typing import Any
|
5
5
|
import time
|
6
6
|
|
7
|
-
from typing import
|
7
|
+
from typing import Iterable
|
8
8
|
from prompt_toolkit import ANSI
|
9
9
|
from prompt_toolkit.application import get_app
|
10
10
|
from prompt_toolkit.buffer import Buffer
|
@@ -12,79 +12,40 @@ from prompt_toolkit.formatted_text import to_formatted_text, fragment_list_to_te
|
|
12
12
|
from prompt_toolkit.formatted_text.base import OneStyleAndTextTuple
|
13
13
|
from prompt_toolkit.layout.processors import Processor, Transformation
|
14
14
|
from prompt_toolkit.application.current import get_app
|
15
|
-
from prompt_toolkit.
|
16
|
-
from prompt_toolkit.buffer import Buffer, BufferAcceptHandler
|
17
|
-
from prompt_toolkit.completion import Completer, DynamicCompleter
|
15
|
+
from prompt_toolkit.buffer import Buffer
|
18
16
|
from prompt_toolkit.document import Document
|
19
17
|
from prompt_toolkit.data_structures import Point
|
20
|
-
from prompt_toolkit.layout.controls import
|
21
|
-
from prompt_toolkit.lexers import Lexer
|
18
|
+
from prompt_toolkit.layout.controls import UIContent
|
19
|
+
from prompt_toolkit.lexers import Lexer
|
22
20
|
from prompt_toolkit.mouse_events import MouseButton, MouseEvent, MouseEventType
|
23
|
-
from prompt_toolkit.
|
24
|
-
from prompt_toolkit.
|
25
|
-
from prompt_toolkit.buffer import Buffer, BufferAcceptHandler, BufferEventHandler, ValidationState, CompletionState, YankNthArgState
|
21
|
+
from prompt_toolkit.selection import SelectionType
|
22
|
+
from prompt_toolkit.buffer import Buffer, ValidationState
|
26
23
|
|
27
24
|
from prompt_toolkit.filters import (
|
28
|
-
Condition,
|
29
25
|
FilterOrBool,
|
30
|
-
has_focus,
|
31
|
-
is_done,
|
32
|
-
is_true,
|
33
|
-
to_filter,
|
34
26
|
)
|
35
27
|
from prompt_toolkit.formatted_text import (
|
36
|
-
AnyFormattedText,
|
37
28
|
StyleAndTextTuples,
|
38
|
-
Template,
|
39
29
|
to_formatted_text,
|
40
30
|
)
|
41
31
|
from prompt_toolkit.formatted_text.utils import fragment_list_to_text
|
42
|
-
from prompt_toolkit.history import
|
43
|
-
from prompt_toolkit.key_binding.key_bindings import
|
44
|
-
from prompt_toolkit.key_binding.key_processor import KeyPressEvent
|
45
|
-
from prompt_toolkit.keys import Keys
|
46
|
-
from prompt_toolkit.search import SearchState
|
32
|
+
from prompt_toolkit.history import InMemoryHistory
|
33
|
+
from prompt_toolkit.key_binding.key_bindings import KeyBindingsBase
|
47
34
|
from prompt_toolkit.layout.containers import (
|
48
|
-
AnyContainer,
|
49
|
-
ColorColumn,
|
50
|
-
ConditionalContainer,
|
51
|
-
Container,
|
52
|
-
DynamicContainer,
|
53
|
-
Float,
|
54
|
-
FloatContainer,
|
55
|
-
HSplit,
|
56
|
-
ScrollOffsets,
|
57
|
-
VSplit,
|
58
35
|
Window,
|
59
36
|
WindowAlign,
|
60
37
|
)
|
61
38
|
from prompt_toolkit.layout.controls import (
|
62
39
|
BufferControl,
|
63
40
|
FormattedTextControl,
|
64
|
-
GetLinePrefixCallable,
|
65
|
-
)
|
66
|
-
from prompt_toolkit.layout.dimension import AnyDimension
|
67
|
-
from prompt_toolkit.layout.dimension import Dimension as D
|
68
|
-
from prompt_toolkit.layout.dimension import to_dimension
|
69
|
-
from prompt_toolkit.layout.margins import (
|
70
|
-
ConditionalMargin,
|
71
|
-
Margin,
|
72
|
-
NumberedMargin,
|
73
|
-
ScrollbarMargin,
|
74
41
|
)
|
75
42
|
from prompt_toolkit.layout.processors import (
|
76
|
-
AppendAutoSuggestion,
|
77
|
-
BeforeInput,
|
78
|
-
ConditionalProcessor,
|
79
|
-
PasswordProcessor,
|
80
43
|
Processor,
|
81
|
-
TabsProcessor,
|
82
44
|
)
|
83
|
-
from prompt_toolkit.lexers import
|
45
|
+
from prompt_toolkit.lexers import Lexer
|
84
46
|
from prompt_toolkit.mouse_events import MouseEvent, MouseEventType
|
85
47
|
from prompt_toolkit.utils import get_cwidth
|
86
|
-
from prompt_toolkit.
|
87
|
-
from prompt_toolkit.widgets import Button, Dialog, Label, MenuContainer, MenuItem, TextArea, SystemToolbar, Frame
|
48
|
+
from prompt_toolkit.widgets import Button, MenuContainer, MenuItem
|
88
49
|
from prompt_toolkit.widgets.base import Border
|
89
50
|
|
90
51
|
from prompt_toolkit.layout.screen import _CHAR_CACHE, Screen, WritePosition
|
@@ -93,7 +54,6 @@ from prompt_toolkit.formatted_text.utils import (
|
|
93
54
|
fragment_list_to_text,
|
94
55
|
fragment_list_width,
|
95
56
|
)
|
96
|
-
from prompt_toolkit.utils import Event
|
97
57
|
|
98
58
|
from .settings import Settings
|
99
59
|
|
@@ -1011,6 +971,26 @@ class MenuItem:
|
|
1011
971
|
|
1012
972
|
|
1013
973
|
class DotDict(dict):
|
974
|
+
"""
|
975
|
+
可以通过点.访问内部key-value对的字典。此类型继承自dict。
|
976
|
+
|
977
|
+
- 由于继承关系,此类型可以使用所有dict可以使用的方法
|
978
|
+
- 额外增加的点.访问方法使用示例如下
|
979
|
+
|
980
|
+
示例:
|
981
|
+
.. code:: Python
|
982
|
+
|
983
|
+
mydict = DotDict()
|
984
|
+
|
985
|
+
# 以下写内容访问等价
|
986
|
+
mydict["key1"] = "value1"
|
987
|
+
mydict.key1 = "value1"
|
988
|
+
|
989
|
+
# 以下读访问等价
|
990
|
+
val = mydict["key1"]
|
991
|
+
val = mydict.key1
|
992
|
+
"""
|
993
|
+
|
1014
994
|
def __getattr__(self, __key):
|
1015
995
|
if (not __key in self.__dict__) and (not __key.startswith("__")):
|
1016
996
|
return self.__getitem__(__key)
|
@@ -1031,6 +1011,15 @@ import importlib
|
|
1031
1011
|
import importlib.util
|
1032
1012
|
|
1033
1013
|
class Plugin:
|
1014
|
+
"""
|
1015
|
+
插件管理类。对加载的插件文件进行管理。该类型由PyMudApp进行管理,无需人工创建。
|
1016
|
+
|
1017
|
+
有关插件的详细信息,请参见 `插件 <plugins.html>`_
|
1018
|
+
|
1019
|
+
:param name: 插件的文件名, 如'myplugin.py'
|
1020
|
+
:param location: 插件所在的目录。自动加载的插件包括PyMUD包目录下的plugins目录以及当前目录下的plugins目录
|
1021
|
+
|
1022
|
+
"""
|
1034
1023
|
def __init__(self, name, location):
|
1035
1024
|
self._plugin_file = name
|
1036
1025
|
self._plugin_loc = location
|
@@ -1038,6 +1027,7 @@ class Plugin:
|
|
1038
1027
|
self.reload()
|
1039
1028
|
|
1040
1029
|
def reload(self):
|
1030
|
+
"加载/重新加载插件对象"
|
1041
1031
|
#del self.modspec, self.mod
|
1042
1032
|
self.modspec = importlib.util.spec_from_file_location(self._plugin_file[:-3], self._plugin_loc)
|
1043
1033
|
self.mod = importlib.util.module_from_spec(self.modspec)
|
@@ -1049,23 +1039,41 @@ class Plugin:
|
|
1049
1039
|
|
1050
1040
|
@property
|
1051
1041
|
def name(self):
|
1042
|
+
"插件名称,由插件文件中的 PLUGIN_NAME 常量定义"
|
1052
1043
|
return self.mod.__dict__["PLUGIN_NAME"]
|
1053
1044
|
|
1054
1045
|
@property
|
1055
1046
|
def desc(self):
|
1047
|
+
"插件描述,由插件文件中的 PLUGIN_DESC 常量定义"
|
1056
1048
|
return self.mod.__dict__["PLUGIN_DESC"]
|
1057
1049
|
|
1058
1050
|
@property
|
1059
1051
|
def help(self):
|
1052
|
+
"插件帮助,由插件文件中的文档字符串定义"
|
1060
1053
|
return self.mod.__doc__
|
1061
1054
|
|
1062
1055
|
def onAppInit(self, app):
|
1056
|
+
"""
|
1057
|
+
PyMUD应用启动时对插件执行的操作,由插件文件中的 PLUGIN_PYMUD_START 函数定义
|
1058
|
+
|
1059
|
+
:param app: 启动的 PyMudApp 对象实例
|
1060
|
+
"""
|
1063
1061
|
self._app_init(app)
|
1064
1062
|
|
1065
1063
|
def onSessionCreate(self, session):
|
1064
|
+
"""
|
1065
|
+
新会话创建时对插件执行的操作,由插件文件中的 PLUGIN_SESSION_CREATE 函数定义
|
1066
|
+
|
1067
|
+
:param session: 新创建的会话对象实例
|
1068
|
+
"""
|
1066
1069
|
self._session_create(session)
|
1067
1070
|
|
1068
1071
|
def onSessionDestroy(self, session):
|
1072
|
+
"""
|
1073
|
+
会话关闭时(注意不是断开)对插件执行的操作,由插件文件中的 PLUGIN_SESSION_DESTROY 函数定义
|
1074
|
+
|
1075
|
+
:param session: 所关闭的会话对象实例
|
1076
|
+
"""
|
1069
1077
|
self._session_destroy(session)
|
1070
1078
|
|
1071
1079
|
def __getattr__(self, __name: str) -> Any:
|