pymud 0.21.0a1__py3-none-any.whl → 0.21.0a3__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 +16 -15
- pymud/__main__.py +3 -3
- pymud/dialogs.py +160 -160
- pymud/extras.py +942 -942
- pymud/i18n.py +41 -41
- pymud/lang/i18n_chs.py +204 -204
- pymud/lang/i18n_eng.py +42 -42
- pymud/logger.py +162 -162
- pymud/main.py +206 -206
- pymud/modules.py +431 -371
- pymud/objects.py +1030 -1028
- pymud/pkuxkx.py +263 -67
- pymud/protocol.py +1008 -1008
- pymud/pymud.py +1292 -1292
- pymud/session.py +3392 -3361
- pymud/settings.py +193 -191
- {pymud-0.21.0a1.dist-info → pymud-0.21.0a3.dist-info}/METADATA +369 -370
- pymud-0.21.0a3.dist-info/RECORD +22 -0
- {pymud-0.21.0a1.dist-info → pymud-0.21.0a3.dist-info}/licenses/LICENSE.txt +674 -674
- pymud-0.21.0a1.dist-info/RECORD +0 -22
- {pymud-0.21.0a1.dist-info → pymud-0.21.0a3.dist-info}/WHEEL +0 -0
- {pymud-0.21.0a1.dist-info → pymud-0.21.0a3.dist-info}/entry_points.txt +0 -0
- {pymud-0.21.0a1.dist-info → pymud-0.21.0a3.dist-info}/top_level.txt +0 -0
pymud/__init__.py
CHANGED
@@ -1,16 +1,17 @@
|
|
1
|
-
from .settings import Settings
|
2
|
-
from .pymud import PyMudApp
|
3
|
-
from .modules import IConfig, PymudDecorator, PymudMeta, alias, trigger, timer, gmcp
|
4
|
-
from .objects import CodeBlock, Alias, SimpleAlias, Trigger, SimpleTrigger, Command, SimpleCommand, Timer, SimpleTimer, GMCPTrigger
|
5
|
-
from .extras import DotDict
|
6
|
-
from .session import Session
|
7
|
-
from .logger import Logger
|
8
|
-
from .main import main
|
9
|
-
|
10
|
-
__all__ = [
|
11
|
-
"PymudDecorator", "PymudMeta", "alias", "trigger", "timer", "gmcp",
|
12
|
-
"IConfig", "PyMudApp", "Settings", "CodeBlock",
|
13
|
-
"Alias", "SimpleAlias", "Trigger", "SimpleTrigger",
|
14
|
-
"Command", "SimpleCommand", "Timer", "SimpleTimer",
|
15
|
-
"GMCPTrigger", "Session", "DotDict", "Logger", "main"
|
1
|
+
from .settings import Settings
|
2
|
+
from .pymud import PyMudApp
|
3
|
+
from .modules import IConfig, PymudDecorator, PymudMeta, alias, trigger, timer, gmcp
|
4
|
+
from .objects import CodeBlock, Alias, SimpleAlias, Trigger, SimpleTrigger, Command, SimpleCommand, Timer, SimpleTimer, GMCPTrigger
|
5
|
+
from .extras import DotDict
|
6
|
+
from .session import Session, exception, async_exception
|
7
|
+
from .logger import Logger
|
8
|
+
from .main import main
|
9
|
+
|
10
|
+
__all__ = [
|
11
|
+
"PymudDecorator", "PymudMeta", "alias", "trigger", "timer", "gmcp",
|
12
|
+
"IConfig", "PyMudApp", "Settings", "CodeBlock",
|
13
|
+
"Alias", "SimpleAlias", "Trigger", "SimpleTrigger",
|
14
|
+
"Command", "SimpleCommand", "Timer", "SimpleTimer",
|
15
|
+
"GMCPTrigger", "Session", "DotDict", "Logger", "main",
|
16
|
+
"exception", "async_exception"
|
16
17
|
]
|
pymud/__main__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
from .main import main
|
2
|
-
|
3
|
-
if __name__ == "__main__":
|
1
|
+
from .main import main
|
2
|
+
|
3
|
+
if __name__ == "__main__":
|
4
4
|
main()
|
pymud/dialogs.py
CHANGED
@@ -1,161 +1,161 @@
|
|
1
|
-
import asyncio, webbrowser
|
2
|
-
|
3
|
-
from prompt_toolkit.layout import AnyContainer, ConditionalContainer, Float, VSplit, HSplit, Window, WindowAlign, ScrollablePane, ScrollOffsets
|
4
|
-
from prompt_toolkit.widgets import Button, Dialog, Label, MenuContainer, MenuItem, TextArea, SystemToolbar, Frame, RadioList
|
5
|
-
from prompt_toolkit.layout.dimension import Dimension, D
|
6
|
-
from prompt_toolkit import ANSI, HTML
|
7
|
-
from prompt_toolkit.mouse_events import MouseEvent, MouseEventType
|
8
|
-
from prompt_toolkit.formatted_text import FormattedText
|
9
|
-
from prompt_toolkit.application.current import get_app
|
10
|
-
from .extras import EasternButton
|
11
|
-
|
12
|
-
from .settings import Settings
|
13
|
-
|
14
|
-
class BasicDialog:
|
15
|
-
def __init__(self, title = "", modal = True):
|
16
|
-
self.future = asyncio.Future()
|
17
|
-
self.dialog = Dialog(
|
18
|
-
body = self.create_body(),
|
19
|
-
title = title,
|
20
|
-
buttons = self.create_buttons(),
|
21
|
-
modal = modal,
|
22
|
-
width = D(preferred=80),
|
23
|
-
)
|
24
|
-
|
25
|
-
def set_done(self, result = True):
|
26
|
-
self.future.set_result(result)
|
27
|
-
|
28
|
-
def create_body(self) -> AnyContainer:
|
29
|
-
return HSplit([Label(text=Settings.gettext("basic_dialog"))])
|
30
|
-
|
31
|
-
def create_buttons(self):
|
32
|
-
ok_button = EasternButton(text=Settings.gettext("ok"), handler=(lambda: self.set_done()))
|
33
|
-
return [ok_button]
|
34
|
-
|
35
|
-
def set_exception(self, exc):
|
36
|
-
self.future.set_exception(exc)
|
37
|
-
|
38
|
-
def __pt_container__(self):
|
39
|
-
return self.dialog
|
40
|
-
|
41
|
-
class MessageDialog(BasicDialog):
|
42
|
-
def __init__(self, title="", message = "", modal=True):
|
43
|
-
self.message = message
|
44
|
-
super().__init__(title, modal)
|
45
|
-
|
46
|
-
def create_body(self) -> AnyContainer:
|
47
|
-
return HSplit([Label(text=self.message)])
|
48
|
-
|
49
|
-
class QueryDialog(BasicDialog):
|
50
|
-
def __init__(self, title="", message = "", modal=True):
|
51
|
-
self.message = message
|
52
|
-
super().__init__(title, modal)
|
53
|
-
|
54
|
-
def create_body(self) -> AnyContainer:
|
55
|
-
return HSplit([Label(text=self.message)])
|
56
|
-
|
57
|
-
def create_buttons(self):
|
58
|
-
ok_button = EasternButton(text=Settings.gettext("ok"), handler=(lambda: self.set_done(True)))
|
59
|
-
cancel_button = EasternButton(text=Settings.gettext("cancel"), handler=(lambda: self.set_done(False)))
|
60
|
-
return [ok_button, cancel_button]
|
61
|
-
|
62
|
-
class WelcomeDialog(BasicDialog):
|
63
|
-
def __init__(self, modal=True):
|
64
|
-
self.website = FormattedText(
|
65
|
-
[('', f'{Settings.gettext("visit")} '),
|
66
|
-
#('class:b', 'GitHub:'),
|
67
|
-
('', Settings.__website__, self.open_url),
|
68
|
-
('', f' {Settings.gettext("displayhelp")}')]
|
69
|
-
)
|
70
|
-
super().__init__("PYMUD", modal)
|
71
|
-
|
72
|
-
def open_url(self, event: MouseEvent):
|
73
|
-
if event.event_type == MouseEventType.MOUSE_UP:
|
74
|
-
webbrowser.open(Settings.__website__)
|
75
|
-
|
76
|
-
def create_body(self) -> AnyContainer:
|
77
|
-
import platform, sys
|
78
|
-
body = HSplit([
|
79
|
-
Window(height=1),
|
80
|
-
Label(HTML(Settings.gettext("appinfo", Settings.__version__, Settings.__release__)), align=WindowAlign.CENTER),
|
81
|
-
Label(HTML(Settings.gettext("author", Settings.__author__, Settings.__email__)), align=WindowAlign.CENTER),
|
82
|
-
Label(self.website, align=WindowAlign.CENTER),
|
83
|
-
Label(Settings.gettext("sysversion", platform.system(), platform.version(), platform.python_version()), align = WindowAlign.CENTER),
|
84
|
-
|
85
|
-
Window(height=1),
|
86
|
-
])
|
87
|
-
|
88
|
-
return body
|
89
|
-
|
90
|
-
class NewSessionDialog(BasicDialog):
|
91
|
-
def __init__(self):
|
92
|
-
super().__init__(Settings.gettext("new_session"), True)
|
93
|
-
|
94
|
-
def create_body(self) -> AnyContainer:
|
95
|
-
body = HSplit([
|
96
|
-
VSplit([
|
97
|
-
HSplit([
|
98
|
-
Label(f" {Settings.gettext("sessionname")}:"),
|
99
|
-
Frame(body=TextArea(name = "session", text="session", multiline=False, wrap_lines=False, height = 1, dont_extend_height=True, width = D(preferred=10), focus_on_click=True, read_only=False),)
|
100
|
-
]),
|
101
|
-
HSplit([
|
102
|
-
Label(f" {Settings.gettext("host")}:"),
|
103
|
-
Frame(body=TextArea(name = "host", text="mud.pkuxkx.net", multiline=False, wrap_lines=False, height = 1, dont_extend_height=True, width = D(preferred=20), focus_on_click=True, read_only=False),)
|
104
|
-
]),
|
105
|
-
HSplit([
|
106
|
-
Label(f" {Settings.gettext("port")}:"),
|
107
|
-
Frame(body=TextArea(name = "port", text="8081", multiline=False, wrap_lines=False, height = 1, dont_extend_height=True, width = D(max=8), focus_on_click=True, read_only=False),)
|
108
|
-
]),
|
109
|
-
HSplit([
|
110
|
-
Label(f" {Settings.gettext("encoding")}:"),
|
111
|
-
Frame(body=TextArea(name = "encoding", text="utf8", multiline=False, wrap_lines=False, height = 1, dont_extend_height=True, width = D(max=8), focus_on_click=True, read_only=False),)
|
112
|
-
]),
|
113
|
-
])
|
114
|
-
])
|
115
|
-
|
116
|
-
return body
|
117
|
-
|
118
|
-
def create_buttons(self):
|
119
|
-
ok_button = EasternButton(text=Settings.gettext("ok"), handler=self.btn_ok_clicked)
|
120
|
-
cancel_button = EasternButton(text=Settings.gettext("cancel"), handler=(lambda: self.set_done(False)))
|
121
|
-
return [ok_button, cancel_button]
|
122
|
-
|
123
|
-
def btn_ok_clicked(self):
|
124
|
-
name = get_app().layout.get_buffer_by_name("session").text
|
125
|
-
host = get_app().layout.get_buffer_by_name("host").text
|
126
|
-
port = int(get_app().layout.get_buffer_by_name("port").text)
|
127
|
-
encoding = get_app().layout.get_buffer_by_name("encoding").text
|
128
|
-
result = (name, host, port, encoding)
|
129
|
-
self.set_done(result)
|
130
|
-
|
131
|
-
|
132
|
-
class LogSelectionDialog(BasicDialog):
|
133
|
-
def __init__(self, text, values, modal=True):
|
134
|
-
self._header_text = text
|
135
|
-
self._selection_values = values
|
136
|
-
self._itemsCount = len(values)
|
137
|
-
if len(values) > 0:
|
138
|
-
self._radio_list = RadioList(values = self._selection_values)
|
139
|
-
else:
|
140
|
-
self._radio_list = Label(Settings.gettext("nolog").center(13))
|
141
|
-
super().__init__(Settings.gettext("chooselog"), modal)
|
142
|
-
|
143
|
-
def create_body(self) -> AnyContainer:
|
144
|
-
body=HSplit([
|
145
|
-
Label(text = self._header_text, dont_extend_height=True),
|
146
|
-
self._radio_list
|
147
|
-
])
|
148
|
-
return body
|
149
|
-
|
150
|
-
def create_buttons(self):
|
151
|
-
ok_button = EasternButton(text=Settings.gettext("ok"), handler=self.btn_ok_clicked)
|
152
|
-
cancel_button = EasternButton(text=Settings.gettext("cancel"), handler=(lambda: self.set_done(False)))
|
153
|
-
return [ok_button, cancel_button]
|
154
|
-
|
155
|
-
def btn_ok_clicked(self):
|
156
|
-
if self._itemsCount:
|
157
|
-
result = self._radio_list.current_value
|
158
|
-
self.set_done(result)
|
159
|
-
else:
|
160
|
-
self.set_done(False)
|
1
|
+
import asyncio, webbrowser
|
2
|
+
|
3
|
+
from prompt_toolkit.layout import AnyContainer, ConditionalContainer, Float, VSplit, HSplit, Window, WindowAlign, ScrollablePane, ScrollOffsets
|
4
|
+
from prompt_toolkit.widgets import Button, Dialog, Label, MenuContainer, MenuItem, TextArea, SystemToolbar, Frame, RadioList
|
5
|
+
from prompt_toolkit.layout.dimension import Dimension, D
|
6
|
+
from prompt_toolkit import ANSI, HTML
|
7
|
+
from prompt_toolkit.mouse_events import MouseEvent, MouseEventType
|
8
|
+
from prompt_toolkit.formatted_text import FormattedText
|
9
|
+
from prompt_toolkit.application.current import get_app
|
10
|
+
from .extras import EasternButton
|
11
|
+
|
12
|
+
from .settings import Settings
|
13
|
+
|
14
|
+
class BasicDialog:
|
15
|
+
def __init__(self, title = "", modal = True):
|
16
|
+
self.future = asyncio.Future()
|
17
|
+
self.dialog = Dialog(
|
18
|
+
body = self.create_body(),
|
19
|
+
title = title,
|
20
|
+
buttons = self.create_buttons(),
|
21
|
+
modal = modal,
|
22
|
+
width = D(preferred=80),
|
23
|
+
)
|
24
|
+
|
25
|
+
def set_done(self, result = True):
|
26
|
+
self.future.set_result(result)
|
27
|
+
|
28
|
+
def create_body(self) -> AnyContainer:
|
29
|
+
return HSplit([Label(text=Settings.gettext("basic_dialog"))])
|
30
|
+
|
31
|
+
def create_buttons(self):
|
32
|
+
ok_button = EasternButton(text=Settings.gettext("ok"), handler=(lambda: self.set_done()))
|
33
|
+
return [ok_button]
|
34
|
+
|
35
|
+
def set_exception(self, exc):
|
36
|
+
self.future.set_exception(exc)
|
37
|
+
|
38
|
+
def __pt_container__(self):
|
39
|
+
return self.dialog
|
40
|
+
|
41
|
+
class MessageDialog(BasicDialog):
|
42
|
+
def __init__(self, title="", message = "", modal=True):
|
43
|
+
self.message = message
|
44
|
+
super().__init__(title, modal)
|
45
|
+
|
46
|
+
def create_body(self) -> AnyContainer:
|
47
|
+
return HSplit([Label(text=self.message)])
|
48
|
+
|
49
|
+
class QueryDialog(BasicDialog):
|
50
|
+
def __init__(self, title="", message = "", modal=True):
|
51
|
+
self.message = message
|
52
|
+
super().__init__(title, modal)
|
53
|
+
|
54
|
+
def create_body(self) -> AnyContainer:
|
55
|
+
return HSplit([Label(text=self.message)])
|
56
|
+
|
57
|
+
def create_buttons(self):
|
58
|
+
ok_button = EasternButton(text=Settings.gettext("ok"), handler=(lambda: self.set_done(True)))
|
59
|
+
cancel_button = EasternButton(text=Settings.gettext("cancel"), handler=(lambda: self.set_done(False)))
|
60
|
+
return [ok_button, cancel_button]
|
61
|
+
|
62
|
+
class WelcomeDialog(BasicDialog):
|
63
|
+
def __init__(self, modal=True):
|
64
|
+
self.website = FormattedText(
|
65
|
+
[('', f'{Settings.gettext("visit")} '),
|
66
|
+
#('class:b', 'GitHub:'),
|
67
|
+
('', Settings.__website__, self.open_url),
|
68
|
+
('', f' {Settings.gettext("displayhelp")}')]
|
69
|
+
)
|
70
|
+
super().__init__("PYMUD", modal)
|
71
|
+
|
72
|
+
def open_url(self, event: MouseEvent):
|
73
|
+
if event.event_type == MouseEventType.MOUSE_UP:
|
74
|
+
webbrowser.open(Settings.__website__)
|
75
|
+
|
76
|
+
def create_body(self) -> AnyContainer:
|
77
|
+
import platform, sys
|
78
|
+
body = HSplit([
|
79
|
+
Window(height=1),
|
80
|
+
Label(HTML(Settings.gettext("appinfo", Settings.__version__, Settings.__release__)), align=WindowAlign.CENTER),
|
81
|
+
Label(HTML(Settings.gettext("author", Settings.__author__, Settings.__email__)), align=WindowAlign.CENTER),
|
82
|
+
Label(self.website, align=WindowAlign.CENTER),
|
83
|
+
Label(Settings.gettext("sysversion", platform.system(), platform.version(), platform.python_version()), align = WindowAlign.CENTER),
|
84
|
+
|
85
|
+
Window(height=1),
|
86
|
+
])
|
87
|
+
|
88
|
+
return body
|
89
|
+
|
90
|
+
class NewSessionDialog(BasicDialog):
|
91
|
+
def __init__(self):
|
92
|
+
super().__init__(Settings.gettext("new_session"), True)
|
93
|
+
|
94
|
+
def create_body(self) -> AnyContainer:
|
95
|
+
body = HSplit([
|
96
|
+
VSplit([
|
97
|
+
HSplit([
|
98
|
+
Label(f" {Settings.gettext("sessionname")}:"),
|
99
|
+
Frame(body=TextArea(name = "session", text="session", multiline=False, wrap_lines=False, height = 1, dont_extend_height=True, width = D(preferred=10), focus_on_click=True, read_only=False),)
|
100
|
+
]),
|
101
|
+
HSplit([
|
102
|
+
Label(f" {Settings.gettext("host")}:"),
|
103
|
+
Frame(body=TextArea(name = "host", text="mud.pkuxkx.net", multiline=False, wrap_lines=False, height = 1, dont_extend_height=True, width = D(preferred=20), focus_on_click=True, read_only=False),)
|
104
|
+
]),
|
105
|
+
HSplit([
|
106
|
+
Label(f" {Settings.gettext("port")}:"),
|
107
|
+
Frame(body=TextArea(name = "port", text="8081", multiline=False, wrap_lines=False, height = 1, dont_extend_height=True, width = D(max=8), focus_on_click=True, read_only=False),)
|
108
|
+
]),
|
109
|
+
HSplit([
|
110
|
+
Label(f" {Settings.gettext("encoding")}:"),
|
111
|
+
Frame(body=TextArea(name = "encoding", text="utf8", multiline=False, wrap_lines=False, height = 1, dont_extend_height=True, width = D(max=8), focus_on_click=True, read_only=False),)
|
112
|
+
]),
|
113
|
+
])
|
114
|
+
])
|
115
|
+
|
116
|
+
return body
|
117
|
+
|
118
|
+
def create_buttons(self):
|
119
|
+
ok_button = EasternButton(text=Settings.gettext("ok"), handler=self.btn_ok_clicked)
|
120
|
+
cancel_button = EasternButton(text=Settings.gettext("cancel"), handler=(lambda: self.set_done(False)))
|
121
|
+
return [ok_button, cancel_button]
|
122
|
+
|
123
|
+
def btn_ok_clicked(self):
|
124
|
+
name = get_app().layout.get_buffer_by_name("session").text
|
125
|
+
host = get_app().layout.get_buffer_by_name("host").text
|
126
|
+
port = int(get_app().layout.get_buffer_by_name("port").text)
|
127
|
+
encoding = get_app().layout.get_buffer_by_name("encoding").text
|
128
|
+
result = (name, host, port, encoding)
|
129
|
+
self.set_done(result)
|
130
|
+
|
131
|
+
|
132
|
+
class LogSelectionDialog(BasicDialog):
|
133
|
+
def __init__(self, text, values, modal=True):
|
134
|
+
self._header_text = text
|
135
|
+
self._selection_values = values
|
136
|
+
self._itemsCount = len(values)
|
137
|
+
if len(values) > 0:
|
138
|
+
self._radio_list = RadioList(values = self._selection_values)
|
139
|
+
else:
|
140
|
+
self._radio_list = Label(Settings.gettext("nolog").center(13))
|
141
|
+
super().__init__(Settings.gettext("chooselog"), modal)
|
142
|
+
|
143
|
+
def create_body(self) -> AnyContainer:
|
144
|
+
body=HSplit([
|
145
|
+
Label(text = self._header_text, dont_extend_height=True),
|
146
|
+
self._radio_list
|
147
|
+
])
|
148
|
+
return body
|
149
|
+
|
150
|
+
def create_buttons(self):
|
151
|
+
ok_button = EasternButton(text=Settings.gettext("ok"), handler=self.btn_ok_clicked)
|
152
|
+
cancel_button = EasternButton(text=Settings.gettext("cancel"), handler=(lambda: self.set_done(False)))
|
153
|
+
return [ok_button, cancel_button]
|
154
|
+
|
155
|
+
def btn_ok_clicked(self):
|
156
|
+
if self._itemsCount:
|
157
|
+
result = self._radio_list.current_value
|
158
|
+
self.set_done(result)
|
159
|
+
else:
|
160
|
+
self.set_done(False)
|
161
161
|
|