pymud 0.20.2a1__tar.gz → 0.20.2a2__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.
Files changed (24) hide show
  1. {pymud-0.20.2a1/src/pymud.egg-info → pymud-0.20.2a2}/PKG-INFO +2 -2
  2. {pymud-0.20.2a1 → pymud-0.20.2a2}/README.md +1 -1
  3. {pymud-0.20.2a1 → pymud-0.20.2a2}/pyproject.toml +1 -1
  4. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud/session.py +36 -110
  5. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud/settings.py +2 -2
  6. {pymud-0.20.2a1 → pymud-0.20.2a2/src/pymud.egg-info}/PKG-INFO +2 -2
  7. {pymud-0.20.2a1 → pymud-0.20.2a2}/LICENSE.txt +0 -0
  8. {pymud-0.20.2a1 → pymud-0.20.2a2}/setup.cfg +0 -0
  9. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud/__init__.py +0 -0
  10. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud/__main__.py +0 -0
  11. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud/dialogs.py +0 -0
  12. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud/extras.py +0 -0
  13. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud/logger.py +0 -0
  14. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud/main.py +0 -0
  15. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud/modules.py +0 -0
  16. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud/objects.py +0 -0
  17. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud/pkuxkx.py +0 -0
  18. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud/protocol.py +0 -0
  19. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud/pymud.py +0 -0
  20. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud.egg-info/SOURCES.txt +0 -0
  21. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud.egg-info/dependency_links.txt +0 -0
  22. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud.egg-info/entry_points.txt +0 -0
  23. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud.egg-info/requires.txt +0 -0
  24. {pymud-0.20.2a1 → pymud-0.20.2a2}/src/pymud.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pymud
3
- Version: 0.20.2a1
3
+ Version: 0.20.2a2
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>
@@ -738,7 +738,7 @@ Requires-Dist: prompt-toolkit
738
738
  ## 版本更新信息
739
739
 
740
740
  ## 0.20.2 (2024-11-18)
741
- + 功能调整: MTTS协商中,将256 Color明确写入协商回复。原先仅包含ANSI 和 TrueColor
741
+ + 功能调整: MTTS协商中,将256 Color明确写入协商回复。原先仅包含ANSI 和 TrueColor。推测武庙特殊颜色偶尔不正常与此有关。
742
742
  + 功能调整: 修复了纯文本正则处理,目前理论上支持所有ANSI控制代码的处置,以正确响应纯文本触发器。
743
743
  + 功能调整: 修改了#var和#global的显示实现,提高了变量打印排列的整齐度和辨识度,以适应长值变量和复杂变量。
744
744
 
@@ -32,7 +32,7 @@
32
32
  ## 版本更新信息
33
33
 
34
34
  ## 0.20.2 (2024-11-18)
35
- + 功能调整: MTTS协商中,将256 Color明确写入协商回复。原先仅包含ANSI 和 TrueColor
35
+ + 功能调整: MTTS协商中,将256 Color明确写入协商回复。原先仅包含ANSI 和 TrueColor。推测武庙特殊颜色偶尔不正常与此有关。
36
36
  + 功能调整: 修复了纯文本正则处理,目前理论上支持所有ANSI控制代码的处置,以正确响应纯文本触发器。
37
37
  + 功能调整: 修改了#var和#global的显示实现,提高了变量打印排列的整齐度和辨识度,以适应长值变量和复杂变量。
38
38
 
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
 
3
3
  name = "pymud" # Required
4
- version = "0.20.2a1" # Required
4
+ version = "0.20.2a2" # Required
5
5
  description = "a MUD Client written in Python" # Optional
6
6
  readme = "README.md" # Optional
7
7
  requires-python = ">=3.7"
@@ -1949,7 +1949,6 @@ class Session:
1949
1949
  if remain:
1950
1950
  strlist.append(str[startindex:])
1951
1951
 
1952
- #self.info(f"原: {str}, 分隔为 {printable_length}, 结果为 {strlist}")
1953
1952
  return strlist
1954
1953
 
1955
1954
  def buildDisplayLines(self, vars: DotDict, title: str):
@@ -1962,7 +1961,7 @@ class Session:
1962
1961
  vars_complex = {}
1963
1962
 
1964
1963
  for k, v in vars.items():
1965
- if k in ("%line", "%raw"):
1964
+ if k in ("%line", "%raw", "%copy"):
1966
1965
  continue
1967
1966
 
1968
1967
  if dataclasses.is_dataclass(v) or (isinstance(v, Iterable) and not isinstance(v, str)):
@@ -1997,7 +1996,7 @@ class Session:
1997
1996
  name = key.rjust(KEY_WIDTH + VAR_WIDTH)
1998
1997
 
1999
1998
  value_dis = vars_simple[key].__repr__()
2000
- var_display = "{} = {}".format(name, value_dis)
1999
+ var_display = "{0} = {1}".format(name, value_dis)
2001
2000
 
2002
2001
  if (cursor + wcswidth(var_display) > totalWidth) or (var_count >= vars_per_line):
2003
2002
  display_lines.append(line)
@@ -2035,17 +2034,31 @@ class Session:
2035
2034
  if isinstance(value, dict):
2036
2035
  max_len = self.getMaxLength(value.keys())
2037
2036
  line += '{'
2037
+ display_lines.append(line)
2038
+ line = " " * (left_margin + KEY_WIDTH + 4)
2038
2039
  for k, v in value.items():
2039
- val_line = "{0}: {1},".format(k.ljust(max_len), v)
2040
- line += val_line
2041
- display_lines.append(line)
2042
- line = " " * (left_margin + KEY_WIDTH + 4)
2040
+ subvalue_dis = "{},".format(v.__repr__())
2041
+ allow_len_subvalue = allow_len - max_len - 4
2042
+ if wcswidth(subvalue_dis) > allow_len_subvalue:
2043
+ subvalue_lines = self.splitByPrintableWidth(subvalue_dis, allow_len_subvalue)
2044
+ line += "{0}: ".format(k.ljust(max_len))
2045
+ for subline in subvalue_lines:
2046
+ line += subline
2047
+ display_lines.append(line)
2048
+ line = " " * (left_margin + KEY_WIDTH + 4 + max_len + 2)
2049
+
2050
+ line = " " * (left_margin + KEY_WIDTH + 4)
2051
+ else:
2052
+ val_line = "{0}: {1}".format(k.ljust(max_len), subvalue_dis)
2053
+ line += val_line
2054
+ display_lines.append(line)
2055
+ line = " " * (left_margin + KEY_WIDTH + 4)
2043
2056
  line = line[:-1] + '}'
2044
2057
  display_lines.append(line)
2045
2058
  elif isinstance(value, list):
2046
2059
  line += '['
2047
2060
  for v in value:
2048
- val_line = "{0},".format(v)
2061
+ val_line = "{0},".format(v.__repr__())
2049
2062
  line += val_line
2050
2063
  display_lines.append(line)
2051
2064
  line = " " * (left_margin + KEY_WIDTH + 4)
@@ -2090,61 +2103,6 @@ class Session:
2090
2103
  #args = code.code[2:]
2091
2104
 
2092
2105
  if len(args) == 0:
2093
- # vars = self._variables
2094
- # vars_simple = {}
2095
- # vars_complex = {}
2096
- # for k, v in vars.items():
2097
- # # 不显示line, raw两个系统变量
2098
- # if k in ("%line", "%raw"):
2099
- # continue
2100
-
2101
- # if isinstance(v, Iterable) and not isinstance(v, str):
2102
- # vars_complex[k] = v
2103
- # else:
2104
- # vars_simple[k] = v
2105
-
2106
- # width = self.application.get_width() - 2 # 保留2个字符,防止 > 导致换行
2107
-
2108
- # title = f" VARIABLE LIST IN SESSION {self.name} "
2109
- # left = (width - len(title)) // 2
2110
- # right = width - len(title) - left
2111
- # self.writetobuffer("="*left + title + "="*right, newline = True)
2112
-
2113
- # # print vars in simple, 每个变量占40格,一行可以多个变量
2114
- # # 这里可以考虑调整一下,默认40, 但如果一个变量值太长,则选择占两个位置
2115
- # var_count = len(vars_simple)
2116
- # var_per_line = (width - 2) // 40
2117
- # lines = math.ceil(var_count / var_per_line)
2118
- # left_space = (width - var_per_line * 40) // 2
2119
- # if left_space > 4: left_space = 4
2120
-
2121
- # var_keys = sorted(vars_simple.keys())
2122
-
2123
- # for idx in range(0, lines):
2124
- # start = idx * var_per_line
2125
- # end = (idx + 1) * var_per_line
2126
- # if end > var_count: end = var_count
2127
- # self.writetobuffer(" " * left_space)
2128
- # line_vars = var_keys[start:end]
2129
- # for var in line_vars:
2130
- # repr = vars_simple[var].__repr__()
2131
- # vwidth = 22 - (wcswidth(repr) - len(repr))
2132
- # self.writetobuffer("{0} = {1}".format(var.rjust(20), repr.ljust(vwidth)))
2133
- # #self.writetobuffer("{0:>18} = {1:<19}".format(var, vars_simple[var].__repr__()))
2134
-
2135
- # self.writetobuffer("", newline = True)
2136
-
2137
- # # print vars in complex, 每个变量占1行
2138
- # var_keys = sorted(vars_complex.keys())
2139
- # for key in var_keys:
2140
- # self.writetobuffer(" " * left_space)
2141
- # self.writetobuffer("{0:>20} = {1}".format(key, vars_complex[key].__repr__()), newline = True)
2142
-
2143
- # self.writetobuffer("="*width, newline = True)
2144
- # row, col = self.buffer.document.translate_index_to_position(len(self.buffer.text))
2145
- # if col:
2146
- # self.writetobuffer("", newline = True)
2147
-
2148
2106
  lines = self.buildDisplayLines(self._variables, f" VARIABLE LIST IN SESSION {self.name} ")
2149
2107
 
2150
2108
  for line in lines:
@@ -2153,7 +2111,12 @@ class Session:
2153
2111
  elif len(args) == 1:
2154
2112
  if args[0] in self._variables.keys():
2155
2113
  obj = self.getVariable(args[0])
2156
- self.info(f"变量{args[0]}值为:{obj}")
2114
+ var_dict = {args[0] : obj}
2115
+ lines = self.buildDisplayLines(var_dict, f" VARIABLE [{args[0]}] IN SESSION {self.name} ")
2116
+
2117
+ for line in lines:
2118
+ self.writetobuffer(line, newline = True)
2119
+
2157
2120
  else:
2158
2121
  self.warning(f"当前session中不存在名称为 {args[0]} 的变量")
2159
2122
 
@@ -2165,6 +2128,7 @@ class Session:
2165
2128
  val = args[1]
2166
2129
 
2167
2130
  self.setVariable(args[0], val)
2131
+ self.info(f"成功设置变量 {args[0]} 值为 {val}")
2168
2132
 
2169
2133
  def handle_global(self, code: CodeLine = None, *args, **kwargs):
2170
2134
  '''
@@ -2190,51 +2154,6 @@ class Session:
2190
2154
  #args = code.code[2:]
2191
2155
 
2192
2156
  if len(args) == 0:
2193
- # vars = self.application.globals
2194
- # vars_simple = {}
2195
- # vars_complex = {}
2196
- # for k, v in vars.items():
2197
- # if isinstance(v, Iterable) and not isinstance(v, str):
2198
- # vars_complex[k] = v
2199
- # else:
2200
- # vars_simple[k] = v
2201
-
2202
- # width = self.application.get_width() - 2 # 保留2个字符,防止 > 导致换行
2203
-
2204
- # title = f" GLOBAL VARIABLES LIST "
2205
- # left = (width - len(title)) // 2
2206
- # right = width - len(title) - left
2207
- # self.writetobuffer("="*left + title + "="*right, newline = True)
2208
-
2209
- # # print vars in simple, 每个变量占40格,一行可以多个变量
2210
- # var_count = len(vars_simple)
2211
- # var_per_line = (width - 2) // 40
2212
- # lines = math.ceil(var_count / var_per_line)
2213
- # left_space = (width - var_per_line * 40) // 2
2214
- # if left_space > 4: left_space = 4
2215
-
2216
- # var_keys = sorted(vars_simple.keys())
2217
-
2218
- # for idx in range(0, lines):
2219
- # start = idx * var_per_line
2220
- # end = (idx + 1) * var_per_line
2221
- # if end > var_count: end = var_count
2222
- # self.writetobuffer(" " * left_space)
2223
- # line_vars = var_keys[start:end]
2224
- # for var in line_vars:
2225
- # repr = vars_simple[var].__repr__()
2226
- # vwidth = 22 - (wcswidth(repr) - len(repr))
2227
- # self.writetobuffer("{0} = {1}".format(var.rjust(20), repr.ljust(vwidth)))
2228
-
2229
- # self.writetobuffer("", newline = True)
2230
-
2231
- # # print vars in complex, 每个变量占1行
2232
- # for k, v in vars_complex.items():
2233
- # self.writetobuffer(" " * left_space)
2234
- # self.writetobuffer("{0:>20} = {1}".format(k, v.__repr__()), newline = True)
2235
-
2236
- # self.writetobuffer("="*width, newline = True)
2237
-
2238
2157
  lines = self.buildDisplayLines(self.application.globals, f" GLOBAL VARIABLES LIST ")
2239
2158
 
2240
2159
  for line in lines:
@@ -2243,7 +2162,13 @@ class Session:
2243
2162
  elif len(args) == 1:
2244
2163
  var = args[0]
2245
2164
  if var in self.application.globals.keys():
2246
- self.info("{0:>20} = {1:<22}".format(var, self.application.get_globals(var).__repr__()), "全局变量")
2165
+ # self.info("{0:>20} = {1:<22}".format(var, self.application.get_globals(var).__repr__()), "全局变量")
2166
+
2167
+ var_dict = {var : self.application.get_globals(var)}
2168
+ lines = self.buildDisplayLines(var_dict, f" GLOBAL VARIABLE [{var}] ")
2169
+
2170
+ for line in lines:
2171
+ self.writetobuffer(line, newline = True)
2247
2172
  else:
2248
2173
  self.info("全局空间不存在名称为 {} 的变量".format(var), "全局变量")
2249
2174
 
@@ -2254,6 +2179,7 @@ class Session:
2254
2179
  except:
2255
2180
  val = args[1]
2256
2181
  self.application.set_globals(args[0], val)
2182
+ self.info(f"成功设置全局变量 {args[0]} 值为 {val}")
2257
2183
 
2258
2184
  def _handle_objs(self, name: str, objs: dict, *args):
2259
2185
  if len(args) == 0:
@@ -11,9 +11,9 @@ class Settings:
11
11
  "APP 名称, 默认PYMUD"
12
12
  __appdesc__ = "a MUD client written in Python"
13
13
  "APP 简要描述"
14
- __version__ = "0.20.1"
14
+ __version__ = "0.20.2"
15
15
  "APP 当前版本"
16
- __release__ = "2024-11-16"
16
+ __release__ = "2024-11-18"
17
17
  "APP 当前版本发布日期"
18
18
  __author__ = "本牛(newstart)@北侠"
19
19
  "APP 作者"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pymud
3
- Version: 0.20.2a1
3
+ Version: 0.20.2a2
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>
@@ -738,7 +738,7 @@ Requires-Dist: prompt-toolkit
738
738
  ## 版本更新信息
739
739
 
740
740
  ## 0.20.2 (2024-11-18)
741
- + 功能调整: MTTS协商中,将256 Color明确写入协商回复。原先仅包含ANSI 和 TrueColor
741
+ + 功能调整: MTTS协商中,将256 Color明确写入协商回复。原先仅包含ANSI 和 TrueColor。推测武庙特殊颜色偶尔不正常与此有关。
742
742
  + 功能调整: 修复了纯文本正则处理,目前理论上支持所有ANSI控制代码的处置,以正确响应纯文本触发器。
743
743
  + 功能调整: 修改了#var和#global的显示实现,提高了变量打印排列的整齐度和辨识度,以适应长值变量和复杂变量。
744
744
 
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