mwxlib 0.90.1__py3-none-any.whl → 0.90.3__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.

Potentially problematic release.


This version of mwxlib might be problematic. Click here for more details.

mwx/framework.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Author: Kazuya O'moto <komoto@jeol.co.jp>
6
6
  """
7
- __version__ = "0.90.1"
7
+ __version__ = "0.90.3"
8
8
  __author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
9
9
 
10
10
  from functools import wraps, partial
@@ -47,10 +47,6 @@ def postcall(f):
47
47
  return _f
48
48
 
49
49
 
50
- def skip(v):
51
- v.Skip()
52
-
53
-
54
50
  _speckeys = {
55
51
  wx.WXK_ALT : 'alt',
56
52
  wx.WXK_BACK : 'backspace',
@@ -1146,7 +1142,9 @@ class ShellFrame(MiniFrame):
1146
1142
  evt.Skip()
1147
1143
  self.Bind(wx.EVT_SIZE, on_size)
1148
1144
 
1149
- def skip(v):
1145
+ def dispatch(v):
1146
+ """Fork key events to the debugger."""
1147
+ self.debugger.handler(self.handler.current_event, v)
1150
1148
  if self.debugger.handler.current_state:
1151
1149
  if self.debugger.tracing:
1152
1150
  self.message("Current status is tracing. Press [C-g] to quit.")
@@ -1155,10 +1153,6 @@ class ShellFrame(MiniFrame):
1155
1153
  self.indicator.Value = 7
1156
1154
  v.Skip()
1157
1155
 
1158
- def dispatch(v):
1159
- """Fork key events to the debugger."""
1160
- self.debugger.handler(self.handler.current_event, v)
1161
-
1162
1156
  self.handler.update({ # DNA<ShellFrame>
1163
1157
  None : {
1164
1158
  'debug_begin' : [ None, self.on_debug_begin ],
@@ -1176,9 +1170,9 @@ class ShellFrame(MiniFrame):
1176
1170
  'buffer_caption_reset' : [ None, self.on_buffer_caption ],
1177
1171
  },
1178
1172
  0 : {
1179
- '* pressed' : (0, skip, dispatch), # => debugger
1180
- '* released' : (0, skip, dispatch), # => debugger
1181
- 'C-g pressed' : (0, self.Quit, skip, dispatch), # => debugger
1173
+ '* pressed' : (0, dispatch), # => debugger
1174
+ '* released' : (0, dispatch), # => debugger
1175
+ 'C-g pressed' : (0, self.Quit, dispatch), # => debugger
1182
1176
  'f1 pressed' : (0, self.About),
1183
1177
  'C-f pressed' : (0, self.OnFindText),
1184
1178
  'f3 pressed' : (0, self.OnFindNext),
@@ -1187,8 +1181,6 @@ class ShellFrame(MiniFrame):
1187
1181
  'S-f11 pressed' : (0, _F(self.toggle_window, self.watcher, doc="Toggle watcher")),
1188
1182
  'f12 pressed' : (0, _F(self.Close, alias="close", doc="Close the window")),
1189
1183
  '*f[0-9]* pressed' : (0, ),
1190
- 'M-left pressed' : (0, _F(self.other_window, p=-1)),
1191
- 'M-right pressed' : (0, _F(self.other_window, p=+1)),
1192
1184
  },
1193
1185
  })
1194
1186
 
@@ -1198,11 +1190,13 @@ class ShellFrame(MiniFrame):
1198
1190
  self.set_hookable(self.Scratch)
1199
1191
 
1200
1192
  @self.Scratch.define_key('C-j')
1193
+ @postcall
1201
1194
  def eval_line():
1202
1195
  shell = self.current_shell
1203
1196
  self.Scratch.buffer.py_eval_line(shell.globals, shell.locals)
1204
1197
 
1205
1198
  @self.Scratch.define_key('M-j')
1199
+ @postcall
1206
1200
  def exec_buffer():
1207
1201
  shell = self.current_shell
1208
1202
  self.Scratch.buffer.py_exec_region(shell.globals, shell.locals)
@@ -1739,7 +1733,6 @@ class ShellFrame(MiniFrame):
1739
1733
  self.debugger.editor = book
1740
1734
  self.debugger.watch((book.buffer.filename, line+1))
1741
1735
  self.debugger.send_input('') # clear input
1742
- book.buffer.del_marker(4)
1743
1736
 
1744
1737
  def stop_trace(self, line, book):
1745
1738
  if self.debugger.busy:
@@ -1747,7 +1740,6 @@ class ShellFrame(MiniFrame):
1747
1740
  if self.debugger.tracing:
1748
1741
  self.debugger.editor = None
1749
1742
  self.debugger.unwatch()
1750
- book.buffer.set_marker(line, 4)
1751
1743
 
1752
1744
  def on_trace_begin(self, frame):
1753
1745
  """Called when set-trace."""
@@ -1810,20 +1802,6 @@ class ShellFrame(MiniFrame):
1810
1802
  self.popup_window(self.Help, focus=0)
1811
1803
  self.Help.swap_page(buf)
1812
1804
 
1813
- def other_window(self, p=1):
1814
- "Move focus to other window"
1815
- pages = [x for x in self.get_all_pages() if x.IsShownOnScreen()]
1816
- wnd = wx.Window.FindFocus()
1817
- while wnd:
1818
- if wnd in pages:
1819
- j = (pages.index(wnd) + p) % len(pages)
1820
- obj = pages[j]
1821
- if isinstance(obj, aui.AuiNotebook):
1822
- obj = obj.CurrentPage
1823
- obj.SetFocus()
1824
- break
1825
- wnd = wnd.Parent
1826
-
1827
1805
  def clone_shell(self, target):
1828
1806
  if not hasattr(target, '__dict__'):
1829
1807
  raise TypeError("primitive objects cannot be targeted")
mwx/nutshell.py CHANGED
@@ -7,6 +7,7 @@ Author: Kazuya O'moto <komoto@jeol.co.jp>
7
7
  from functools import wraps
8
8
  from importlib import import_module
9
9
  from pprint import pformat
10
+ from bdb import BdbQuit
10
11
  import traceback
11
12
  import warnings
12
13
  import inspect
@@ -35,14 +36,19 @@ from .framework import CtrlInterface, AuiNotebook, Menu
35
36
  ## URL pattern (flag = re.M | re.A)
36
37
  url_re = r"https?://[\w/:%#$&?()~.=+-]+"
37
38
 
39
+ ## no-file pattern
40
+ nofile_re = r'[\/:*?"<>|]'
41
+
38
42
  ## Python syntax pattern
39
43
  py_indent_re = r"if|else|elif|for|while|with|def|class|try|except|finally"
40
44
  py_outdent_re = r"else:|elif\s+.*:|except(\s+.*)?:|finally:"
41
45
  py_closing_re = r"break|pass|return|raise|continue"
42
46
 
43
47
  ## Python interp traceback pattern
44
- py_error_re = r'^ +File "(.*?)", line ([0-9]+)'
45
- py_frame_re = r"^ +file '(.*?)', line ([0-9]+)"
48
+ py_error_re = r' +File "(.*?)", line ([0-9]+)'
49
+ py_frame_re = r" +file '(.*?)', line ([0-9]+)"
50
+ py_where_re = r'> +([^*?"<>|\r\n]+?):([0-9]+)'
51
+ py_break_re = r'at ([^*?"<>|\r\n]+?):([0-9]+)'
46
52
 
47
53
 
48
54
  def skip(v):
@@ -111,7 +117,7 @@ class EditorInterface(CtrlInterface):
111
117
  'C-t pressed' : (0, ), # overrides transpose-line
112
118
  'C-S-f pressed' : (0, _F(self.set_mark)), # overrides mark
113
119
  'C-space pressed' : (0, _F(self.set_mark)),
114
- 'C-S-space pressed' : (0, _F(self.set_pointer)),
120
+ 'S-space pressed' : (0, _F(self.set_pointer)),
115
121
  'C-backspace pressed' : (0, skip),
116
122
  'S-backspace pressed' : (0, _F(self.backward_kill_line)),
117
123
  'C-tab pressed' : (0, _F(self.insert_space_like_tab)),
@@ -376,6 +382,11 @@ class EditorInterface(CtrlInterface):
376
382
  lambda self,v: self.set_marker(v, 3), # [pointer_set]
377
383
  lambda self: self.del_marker(3)) # [pointer_unset]
378
384
 
385
+ red_pointer = property(
386
+ lambda self: self.get_marker(4),
387
+ lambda self,v: self.set_marker(v, 4), # [red-pointer_set]
388
+ lambda self: self.del_marker(4)) # [red-pointer_unset]
389
+
379
390
  @property
380
391
  def markline(self):
381
392
  return self.MarkerNext(0, 1<<0)
@@ -416,9 +427,10 @@ class EditorInterface(CtrlInterface):
416
427
 
417
428
  def set_pointer(self):
418
429
  if self.pointer == self.cline:
419
- self.pointer = -1 # toggle marker
430
+ self.pointer = -1
420
431
  else:
421
432
  self.pointer = self.cline
433
+ self.red_pointer = -1
422
434
 
423
435
  def exchange_point_and_mark(self):
424
436
  p = self.cpos
@@ -1607,7 +1619,7 @@ class Buffer(EditWindow, EditorInterface):
1607
1619
  ## Python eval / exec
1608
1620
  ## --------------------------------
1609
1621
 
1610
- def py_eval_line(self, globals, locals):
1622
+ def py_eval_line(self, globals=None, locals=None):
1611
1623
  if self.CallTipActive():
1612
1624
  self.CallTipCancel()
1613
1625
 
@@ -1631,7 +1643,7 @@ class Buffer(EditWindow, EditorInterface):
1631
1643
  return
1632
1644
  self.message(status)
1633
1645
 
1634
- def py_exec_region(self, globals, locals, filename=None):
1646
+ def py_exec_region(self, globals=None, locals=None, filename=None):
1635
1647
  if not filename:
1636
1648
  filename = self.filename
1637
1649
  try:
@@ -1639,6 +1651,9 @@ class Buffer(EditWindow, EditorInterface):
1639
1651
  exec(code, globals, locals)
1640
1652
  dispatcher.send(signal='Interpreter.push',
1641
1653
  sender=self, command=None, more=False)
1654
+ except BdbQuit:
1655
+ self.red_pointer = self.cline
1656
+ pass
1642
1657
  except Exception as e:
1643
1658
  msg = traceback.format_exc()
1644
1659
  err = re.findall(py_error_re, msg, re.M)
@@ -1651,7 +1666,7 @@ class Buffer(EditWindow, EditorInterface):
1651
1666
  self.EnsureCaretVisible()
1652
1667
  self.AnnotationSetStyle(lx, stc.STC_STYLE_ANNOTATION)
1653
1668
  self.AnnotationSetText(lx, msg)
1654
- self.message("- {!r}".format(e))
1669
+ self.message("- {}".format(e))
1655
1670
  ## print(msg, file=sys.__stderr__)
1656
1671
  else:
1657
1672
  self.code = code
@@ -2261,7 +2276,7 @@ class Nautilus(Shell, EditorInterface):
2261
2276
  obj.this = inspect.getmodule(obj)
2262
2277
  obj.shell = self # overwrite the facade <wx.py.shell.ShellFacade>
2263
2278
  except AttributeError:
2264
- ## print("- cannot overwrite target vars: {!r}".format(e))
2279
+ ## print("- cannot overwrite target vars: {}".format(e))
2265
2280
  pass
2266
2281
  self.parent.handler('title_window', obj)
2267
2282
 
@@ -2714,6 +2729,7 @@ class Nautilus(Shell, EditorInterface):
2714
2729
  self.goto_char(self.eolc)
2715
2730
  self.promptPosEnd = 0
2716
2731
  self.prompt()
2732
+ self.AnnotationClearAll()
2717
2733
 
2718
2734
  def on_enter_notemode(self, evt):
2719
2735
  self.noteMode = True
@@ -3262,7 +3278,7 @@ class Nautilus(Shell, EditorInterface):
3262
3278
  if lines:
3263
3279
  region = self.get_region(self.cline)
3264
3280
  self.pointer = region[0] + lines[-1] - 1
3265
- self.message("- {!r}".format(e))
3281
+ self.message("- {}".format(e))
3266
3282
  ## print(msg, file=sys.__stderr__)
3267
3283
  else:
3268
3284
  del self.pointer
mwx/wxmon.py CHANGED
@@ -53,10 +53,10 @@ class EventMonitor(CheckList, ListCtrlAutoWidthMixin, CtrlInterface):
53
53
 
54
54
  self.parent = parent
55
55
  self.target = None
56
+ self._target = None # previous target
56
57
 
57
58
  self.Font = wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
58
59
 
59
- self.__prev = None
60
60
  self.__dir = True # sort direction
61
61
  self.__items = []
62
62
 
@@ -128,13 +128,14 @@ class EventMonitor(CheckList, ListCtrlAutoWidthMixin, CtrlInterface):
128
128
  self.clear()
129
129
  self.unwatch()
130
130
  if widget is None:
131
- widget = self.__prev # Restart
131
+ widget = self._target # Resume watching the previous target.
132
132
  if not widget:
133
133
  return
134
134
  if not isinstance(widget, wx.Object):
135
135
  wx.MessageBox("Cannot watch the widget.\n\n"
136
136
  "- {!r} is not a wx.Object.".format(widget))
137
137
  return
138
+ self._target = widget
138
139
  self.target = widget
139
140
  ssmap = self.dump(widget, verbose=0)
140
141
  for binder in self.get_watchlist():
@@ -158,7 +159,6 @@ class EventMonitor(CheckList, ListCtrlAutoWidthMixin, CtrlInterface):
158
159
  if not widget.Unbind(binder, handler=self.onWatchedEvent):
159
160
  print("- Failed to unbind {}: {}".format(binder.typeId, widget))
160
161
  self.parent.handler('monitor_end', widget)
161
- self.__prev = widget
162
162
  self.target = None
163
163
 
164
164
  def onWatchedEvent(self, evt):
@@ -297,7 +297,7 @@ class EventMonitor(CheckList, ListCtrlAutoWidthMixin, CtrlInterface):
297
297
 
298
298
  def OnContextMenu(self, evt):
299
299
  obj = self.target
300
- wnd = self.__prev
300
+ wnd = self._target
301
301
  menu = [
302
302
  (1, "Copy data", Icon('copy'),
303
303
  lambda v: self.copy(),
mwx/wxpdb.py CHANGED
@@ -370,7 +370,7 @@ class Debugger(Pdb):
370
370
  """
371
371
  if self.editor:
372
372
  del self.editor.buffer.pointer
373
- self.editor = None
373
+ self.editor = None
374
374
  self.code = None
375
375
 
376
376
  ## Note: Required to terminate the reader of threading pdb.
mwx/wxwit.py CHANGED
@@ -134,14 +134,6 @@ class Inspector(it.InspectionTree, CtrlInterface):
134
134
  self.target = None
135
135
  self.timer.Stop()
136
136
 
137
- def addref(self, obj, ref='obj'):
138
- shell = self.parent.current_shell
139
- if shell is not obj:
140
- shell.locals[ref] = obj
141
- self.parent.message("self.{} -> {!r}".format(ref, obj))
142
- shell.SetFocus()
143
- return shell
144
-
145
137
  ## --------------------------------
146
138
  ## Actions on tree items
147
139
  ## --------------------------------
@@ -177,16 +169,13 @@ class Inspector(it.InspectionTree, CtrlInterface):
177
169
  valid = (obj is not None)
178
170
  menu = [
179
171
  (1, "&Dive into the shell", Icon('core'),
180
- lambda v: self.parent.clone_shell(obj),
172
+ lambda v: dive(obj),
181
173
  lambda v: v.Enable(valid)),
182
174
 
183
175
  (2, "&Watch the event", Icon('ghost'),
184
- lambda v: self.parent.debug(obj),
176
+ lambda v: debug(obj),
185
177
  lambda v: v.Enable(valid)),
186
178
 
187
- (3, "&Add reference", Icon('tag'),
188
- lambda v: self.addref(obj),
189
- lambda v: v.Enable(valid)),
190
179
  (),
191
180
  (8, "&Filling View", miniIcon('ShowFilling'),
192
181
  lambda v: filling(obj),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mwxlib
3
- Version: 0.90.1
3
+ Version: 0.90.3
4
4
  Summary: A wrapper of matplotlib and wxPython (phoenix)
5
5
  Home-page: https://github.com/komoto48g/mwxlib
6
6
  Author: Kazuya O'moto <komoto@jeol.co.jp>
@@ -1,22 +1,22 @@
1
1
  mwx/__init__.py,sha256=6pnXWrbO-_yuceMClYg0GKpZB5W1DPUPerhjUm4bIXM,2423
2
2
  mwx/controls.py,sha256=6Zin21RWN_yQ7v8FQQjksvJux7Bbi8opMFq1HsbZCVo,46530
3
- mwx/framework.py,sha256=k8wBHdXU6_ixMyK_BKkmD6HFTF3MK4srHHlW8HUF80Q,73430
3
+ mwx/framework.py,sha256=qbF1XwgBkNWT5z8Hbu3IKdvUnDpMZYzxwshZ9r6vctU,72662
4
4
  mwx/graphman.py,sha256=agvuPofnfQoDtTC0Hk_n8OqySb0SqeHoJVMcLi_YVQA,68507
5
5
  mwx/images.py,sha256=mrnUYH12I3XLVSZcEXlpVltX0XMxufbl2yRvDIQJZqc,49957
6
6
  mwx/matplot2.py,sha256=Knecx055Cm25qobhXuNTE1sjDVLABl6IGVAYFAwfyEI,32882
7
7
  mwx/matplot2g.py,sha256=mLy73uchAFkD5SBeeGo_ZI9O5vuhyQei4vqZteEclG4,64959
8
8
  mwx/matplot2lg.py,sha256=Djt0lFtQs_yLK4wOYXLhLsSahgVhCGtYlIIQ8IJkCOA,26311
9
9
  mwx/mgplt.py,sha256=EG5yP2vibFkksiuGrQy_nqRepwtFKk2xg35HbbNz0E0,5742
10
- mwx/nutshell.py,sha256=lgEBUeqBnYWBUUHzKu1CkXY6ckUSDgtHnhAoBYjrYgs,135204
10
+ mwx/nutshell.py,sha256=seOjkLmsfsGRCOrWzOH-fEST8F_SJeC6tp4xNpcaJkM,135740
11
11
  mwx/utilus.py,sha256=YA19NZjCrTHHafqd2sQoA-TV947awCxPPmDLiHSz978,37001
12
- mwx/wxmon.py,sha256=FpuFpARJ055OUWRu18TCESqjV9TfieqT3t_A-kQyAzI,13751
13
- mwx/wxpdb.py,sha256=KQkmFdF-WB4NwQuK5bWY9wzuSffNwDSxtdzqlEq2054,19490
12
+ mwx/wxmon.py,sha256=6ejFMuI7gffewrR7eLbI7BQfqBRYX-ujp2Ru7ofeork,13802
13
+ mwx/wxpdb.py,sha256=8f55jAO856iB61wRidCR3aFjnrHuaC3RZF6kwj1Ok1E,19486
14
14
  mwx/wxwil.py,sha256=uAmpkOQtDGjqywJ8bV-yT5IUANPi9rsMa1CcWVIILeM,5680
15
- mwx/wxwit.py,sha256=BJTnqdoLpWYHQAiUfhzxhF6Nip6Eo-8QoVr3DwtAC3k,8097
15
+ mwx/wxwit.py,sha256=0sskPOE9LTIYI0iokXTmtgPMDxeLAZk3zoFMDH9Xn5g,7656
16
16
  mwx/py/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  mwx/py/filling.py,sha256=f6KMBcBv7gwrl6qmJYLTL-O0Z47bWNAdTCZtUZIo8vM,16794
18
- mwxlib-0.90.1.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
19
- mwxlib-0.90.1.dist-info/METADATA,sha256=7y59AKjewO9YpQgP8yEs4i_HHKldXUHNVKVPB41vQW0,1945
20
- mwxlib-0.90.1.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
21
- mwxlib-0.90.1.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
22
- mwxlib-0.90.1.dist-info/RECORD,,
18
+ mwxlib-0.90.3.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
19
+ mwxlib-0.90.3.dist-info/METADATA,sha256=CEHM1YIueh8YkeDoP2Ype1-QD9DDtgqUGxQFHKMzSj8,1945
20
+ mwxlib-0.90.3.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
21
+ mwxlib-0.90.3.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
22
+ mwxlib-0.90.3.dist-info/RECORD,,