mwxlib 0.99.0__py3-none-any.whl → 1.7.13__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.
- mwx/__init__.py +7 -5
- mwx/bookshelf.py +133 -57
- mwx/controls.py +555 -518
- mwx/framework.py +569 -544
- mwx/graphman.py +708 -702
- mwx/images.py +29 -0
- mwx/matplot2.py +226 -217
- mwx/matplot2g.py +733 -657
- mwx/matplot2lg.py +192 -183
- mwx/mgplt.py +21 -23
- mwx/nutshell.py +1162 -1019
- mwx/plugins/ffmpeg_view.py +74 -76
- mwx/plugins/fft_view.py +14 -16
- mwx/plugins/frame_listview.py +56 -53
- mwx/plugins/line_profile.py +2 -2
- mwx/py/filling.py +9 -8
- mwx/testsuite.py +38 -0
- mwx/utilus.py +273 -208
- mwx/wxmon.py +45 -40
- mwx/wxpdb.py +81 -92
- mwx/wxwil.py +18 -18
- mwx/wxwit.py +49 -51
- {mwxlib-0.99.0.dist-info → mwxlib-1.7.13.dist-info}/METADATA +19 -17
- mwxlib-1.7.13.dist-info/RECORD +28 -0
- {mwxlib-0.99.0.dist-info → mwxlib-1.7.13.dist-info}/WHEEL +1 -1
- mwxlib-0.99.0.dist-info/LICENSE +0 -21
- mwxlib-0.99.0.dist-info/RECORD +0 -28
- {mwxlib-0.99.0.dist-info → mwxlib-1.7.13.dist-info}/top_level.txt +0 -0
mwx/wxpdb.py
CHANGED
|
@@ -27,17 +27,18 @@ echo.verbose = 0
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
class Debugger(Pdb):
|
|
30
|
-
"""Graphical debugger with extended Pdb
|
|
30
|
+
"""Graphical debugger with extended Pdb.
|
|
31
31
|
|
|
32
32
|
Args:
|
|
33
|
-
parent
|
|
34
|
-
stdin
|
|
35
|
-
stdout
|
|
33
|
+
parent: shellframe
|
|
34
|
+
stdin: shell.interp.stdin
|
|
35
|
+
stdout: shell.interp.stdout
|
|
36
36
|
|
|
37
37
|
Attributes:
|
|
38
|
-
editor
|
|
38
|
+
editor: Notebook to show the stack frames
|
|
39
|
+
|
|
40
|
+
Key bindings::
|
|
39
41
|
|
|
40
|
-
Key bindings:
|
|
41
42
|
C-g : quit
|
|
42
43
|
C-q : quit
|
|
43
44
|
C-n : next (step-over)
|
|
@@ -46,27 +47,26 @@ class Debugger(Pdb):
|
|
|
46
47
|
C-b : Set a breakpoint at the current line.
|
|
47
48
|
C-@ : Jump to the first lineno of the code.
|
|
48
49
|
C-S-j : Jump to the lineno of the code.
|
|
49
|
-
C-S-
|
|
50
|
+
C-S-n : Continue execution until the lineno of the code.
|
|
50
51
|
C-w : Stamp current where(frame) message.
|
|
51
52
|
"""
|
|
52
53
|
verbose = False
|
|
53
54
|
use_rawinput = False
|
|
54
55
|
prompt = property(lambda self: self.indents + '(Pdb) ',
|
|
55
|
-
lambda self,v: None)
|
|
56
|
-
parent = property(lambda self: self.__shellframe)
|
|
56
|
+
lambda self, v: None) # fake setter
|
|
57
57
|
handler = property(lambda self: self.__handler)
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
@property
|
|
60
60
|
def interactive_shell(self):
|
|
61
61
|
return self.__shell
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
@interactive_shell.setter
|
|
64
64
|
def interactive_shell(self, v):
|
|
65
65
|
self.__shell = v
|
|
66
|
-
## Don't use rawinput
|
|
66
|
+
## Don't use rawinput.
|
|
67
67
|
self.stdin = self.__shell.interp.stdin
|
|
68
68
|
self.stdout = self.__shell.interp.stdout
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
@property
|
|
71
71
|
def busy(self):
|
|
72
72
|
"""Indicates that the current state is debug mode.
|
|
@@ -79,32 +79,32 @@ class Debugger(Pdb):
|
|
|
79
79
|
return self.curframe is not None
|
|
80
80
|
except AttributeError:
|
|
81
81
|
pass
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
@property
|
|
84
84
|
def tracing(self):
|
|
85
85
|
"""Indicates that the current state is trace mode.
|
|
86
86
|
"""
|
|
87
87
|
## cf. (self.handler.current_state == 2)
|
|
88
88
|
return self.__hookpoint is not None
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
def __init__(self, parent, *args, **kwargs):
|
|
91
91
|
Pdb.__init__(self, *args, **kwargs)
|
|
92
92
|
|
|
93
|
-
self.
|
|
94
|
-
self.__hookpoint = None
|
|
93
|
+
self.parent = parent
|
|
95
94
|
self.indents = ' ' * 2
|
|
96
95
|
self.interactive_shell = parent.rootshell
|
|
97
96
|
self.editor = None
|
|
98
97
|
self.code = None
|
|
98
|
+
self.__hookpoint = None
|
|
99
99
|
|
|
100
100
|
def _input(msg):
|
|
101
|
-
##
|
|
101
|
+
## Redirects input such as cl(ear).
|
|
102
102
|
self.message(msg, indent=0)
|
|
103
103
|
return self.stdin.readline()
|
|
104
104
|
pdb.input = _input
|
|
105
105
|
|
|
106
106
|
def _help():
|
|
107
|
-
self.parent.handler('add_help', pdb.__doc__)
|
|
107
|
+
self.parent.handler('add_help', pdb.__doc__, "pdb")
|
|
108
108
|
pdb.help = _help
|
|
109
109
|
|
|
110
110
|
def dispatch(evt):
|
|
@@ -129,7 +129,7 @@ class Debugger(Pdb):
|
|
|
129
129
|
'C-b pressed' : (1, lambda v: self.set_breakpoint()),
|
|
130
130
|
'C-@ pressed' : (1, lambda v: self.jump_to_entry()),
|
|
131
131
|
'C-S-j pressed' : (1, lambda v: self.jump_to_lineno()),
|
|
132
|
-
'C-S-
|
|
132
|
+
'C-S-n pressed' : (1, lambda v: self.exec_until_lineno()),
|
|
133
133
|
'C-w pressed' : (1, lambda v: self.stamp_where()),
|
|
134
134
|
},
|
|
135
135
|
2 : {
|
|
@@ -138,26 +138,26 @@ class Debugger(Pdb):
|
|
|
138
138
|
'debug_begin' : (1, self.on_debug_begin, dispatch),
|
|
139
139
|
},
|
|
140
140
|
})
|
|
141
|
-
|
|
141
|
+
|
|
142
142
|
def set_breakpoint(self):
|
|
143
143
|
"""Set a breakpoint at the current line."""
|
|
144
144
|
filename = self.curframe.f_code.co_filename
|
|
145
145
|
ln = self.editor.buffer.cline + 1
|
|
146
146
|
if ln not in self.get_file_breaks(filename):
|
|
147
147
|
self.send_input('b {}'.format(ln), echo=True)
|
|
148
|
-
|
|
148
|
+
|
|
149
149
|
def jump_to_entry(self):
|
|
150
150
|
"""Jump to the first lineno of the code."""
|
|
151
151
|
ln = self.editor.buffer.markline + 1
|
|
152
152
|
if ln:
|
|
153
153
|
self.send_input('j {}'.format(ln), echo=True)
|
|
154
|
-
|
|
154
|
+
|
|
155
155
|
def jump_to_lineno(self):
|
|
156
156
|
"""Jump to the lineno of the code."""
|
|
157
157
|
ln = self.editor.buffer.cline + 1
|
|
158
158
|
if ln:
|
|
159
159
|
self.send_input('j {}'.format(ln), echo=True)
|
|
160
|
-
|
|
160
|
+
|
|
161
161
|
def exec_until_lineno(self):
|
|
162
162
|
"""Continue execution until the lineno of the code."""
|
|
163
163
|
frame = self.curframe
|
|
@@ -170,14 +170,14 @@ class Debugger(Pdb):
|
|
|
170
170
|
self.message("--> {}:{}:{}".format(filename, ln, name), indent=0)
|
|
171
171
|
else:
|
|
172
172
|
self.stamp_where()
|
|
173
|
-
|
|
173
|
+
|
|
174
174
|
def stamp_where(self):
|
|
175
175
|
"""Stamp current where(frame) message."""
|
|
176
176
|
## cf. (print_stack_entry for frame in self.stack)
|
|
177
177
|
self.send_input('w')
|
|
178
178
|
if not self.verbose:
|
|
179
179
|
self.message("--> {}".format(where(self.curframe)), indent=0)
|
|
180
|
-
|
|
180
|
+
|
|
181
181
|
def send_input(self, c, echo=False):
|
|
182
182
|
"""Send input:str (echo message if needed)."""
|
|
183
183
|
def _send():
|
|
@@ -185,41 +185,41 @@ class Debugger(Pdb):
|
|
|
185
185
|
if echo or self.verbose:
|
|
186
186
|
self.message(c, indent=0)
|
|
187
187
|
wx.CallAfter(_send)
|
|
188
|
-
|
|
188
|
+
|
|
189
189
|
def message(self, msg, indent=True):
|
|
190
190
|
"""Add prefix and insert msg at the end of command-line."""
|
|
191
191
|
shell = self.interactive_shell
|
|
192
192
|
shell.goto_char(shell.eolc)
|
|
193
193
|
prefix = self.indents if indent else ''
|
|
194
194
|
print("{}{}".format(prefix, msg), file=self.stdout)
|
|
195
|
-
|
|
195
|
+
|
|
196
196
|
def watch(self, bp):
|
|
197
197
|
"""Start tracing."""
|
|
198
|
-
if self.busy:
|
|
198
|
+
if self.busy: # don't set while debugging
|
|
199
199
|
return
|
|
200
200
|
self.__hookpoint = bp
|
|
201
201
|
self.reset()
|
|
202
202
|
sys.settrace(self.trace_dispatch)
|
|
203
203
|
threading.settrace(self.trace_dispatch)
|
|
204
204
|
self.handler('trace_begin', bp)
|
|
205
|
-
|
|
205
|
+
|
|
206
206
|
def unwatch(self):
|
|
207
207
|
"""End tracing."""
|
|
208
|
-
if self.busy:
|
|
208
|
+
if self.busy: # don't unset while debugging
|
|
209
209
|
return
|
|
210
210
|
bp = self.__hookpoint
|
|
211
211
|
self.reset()
|
|
212
212
|
sys.settrace(None)
|
|
213
213
|
threading.settrace(None)
|
|
214
|
-
##
|
|
214
|
+
## Delete bp *after* setting dispatcher -> None.
|
|
215
215
|
self.__hookpoint = None
|
|
216
216
|
if bp:
|
|
217
217
|
self.handler('trace_end', bp)
|
|
218
218
|
else:
|
|
219
|
-
## Called to abort when the debugger is invalid status
|
|
220
|
-
## e.g., (self.handler.current_state > 0 but not busy)
|
|
219
|
+
## Called to abort when the debugger is invalid status.
|
|
220
|
+
## e.g., (self.handler.current_state > 0 but not busy).
|
|
221
221
|
self.handler('abort')
|
|
222
|
-
|
|
222
|
+
|
|
223
223
|
def debug(self, obj, *args, **kwargs):
|
|
224
224
|
"""Debug a callable object.
|
|
225
225
|
"""
|
|
@@ -241,11 +241,10 @@ class Debugger(Pdb):
|
|
|
241
241
|
except Exception as e:
|
|
242
242
|
## Note: post-call to avoid crashing by a kill-focus event.
|
|
243
243
|
wx.CallAfter(wx.MessageBox,
|
|
244
|
-
f"Debugger
|
|
244
|
+
f"Debugger has been closed.\n\n{e}")
|
|
245
245
|
finally:
|
|
246
246
|
self.set_quit()
|
|
247
|
-
|
|
248
|
-
|
|
247
|
+
|
|
249
248
|
def run(self, cmd, filename="<string>"):
|
|
250
249
|
"""Debug a statement executed via the exec() function.
|
|
251
250
|
"""
|
|
@@ -268,38 +267,33 @@ class Debugger(Pdb):
|
|
|
268
267
|
except Exception as e:
|
|
269
268
|
## Note: post-call to avoid crashing by a kill-focus event.
|
|
270
269
|
wx.CallAfter(wx.MessageBox,
|
|
271
|
-
f"Debugger
|
|
270
|
+
f"Debugger has been closed.\n\n{e}")
|
|
272
271
|
finally:
|
|
273
272
|
self.set_quit()
|
|
274
|
-
|
|
275
|
-
|
|
273
|
+
|
|
276
274
|
## --------------------------------
|
|
277
|
-
## Actions for handler
|
|
275
|
+
## Actions for handler.
|
|
278
276
|
## --------------------------------
|
|
279
|
-
|
|
277
|
+
|
|
280
278
|
def _markbp(self, lineno, style):
|
|
281
279
|
"""Add a marker to lineno, with the following style markers:
|
|
282
|
-
[1]
|
|
283
|
-
[2]
|
|
280
|
+
[1] white_arrow for breakpoints
|
|
281
|
+
[2] red_arrow for exceptions
|
|
284
282
|
"""
|
|
285
283
|
if self.editor:
|
|
286
284
|
if lineno:
|
|
287
285
|
self.editor.buffer.MarkerAdd(lineno - 1, style)
|
|
288
286
|
else:
|
|
289
287
|
self.editor.buffer.MarkerDeleteAll(style)
|
|
290
|
-
|
|
288
|
+
|
|
291
289
|
def on_debug_begin(self, frame):
|
|
292
290
|
"""Called before set_trace.
|
|
293
291
|
Note: self.busy -> False or None
|
|
294
292
|
"""
|
|
295
293
|
self.__hookpoint = None
|
|
296
294
|
self.indents = ' ' * 2
|
|
297
|
-
self.stdin.input = ''
|
|
298
|
-
|
|
299
|
-
if wx.IsBusy():
|
|
300
|
-
wx.EndBusyCursor()
|
|
301
|
-
wx.CallAfter(_continue)
|
|
302
|
-
|
|
295
|
+
self.stdin.input = '' # clear stdin buffer
|
|
296
|
+
|
|
303
297
|
def on_debug_mark(self, frame):
|
|
304
298
|
"""Called when interaction."""
|
|
305
299
|
code = frame.f_code
|
|
@@ -311,8 +305,8 @@ class Debugger(Pdb):
|
|
|
311
305
|
module = import_module(m.group(1))
|
|
312
306
|
filename = inspect.getfile(module)
|
|
313
307
|
|
|
314
|
-
editor = self.parent.
|
|
315
|
-
|
|
308
|
+
editor = next(self.parent.get_all_editors(code),
|
|
309
|
+
next(self.parent.get_all_editors(filename), None))
|
|
316
310
|
if not editor:
|
|
317
311
|
editor = self.parent.Log
|
|
318
312
|
## Note: Need a post-call for a thread debugging.
|
|
@@ -323,21 +317,21 @@ class Debugger(Pdb):
|
|
|
323
317
|
self.editor.buffer.SetFocus()
|
|
324
318
|
|
|
325
319
|
for ln in self.get_file_breaks(filename):
|
|
326
|
-
self._markbp(ln, 1)
|
|
320
|
+
self._markbp(ln, 1) # (>>) bp:white-arrow
|
|
327
321
|
|
|
328
322
|
def _mark():
|
|
329
323
|
buffer = self.editor.buffer
|
|
330
324
|
if filename == buffer.filename:
|
|
331
325
|
if code != self.code:
|
|
332
|
-
buffer.markline = firstlineno - 1
|
|
326
|
+
buffer.markline = firstlineno - 1 # (o) entry:mark
|
|
333
327
|
buffer.goto_marker(1)
|
|
334
328
|
buffer.recenter(3)
|
|
335
329
|
buffer.goto_line(lineno - 1)
|
|
336
|
-
buffer.pointer = lineno - 1
|
|
337
|
-
buffer.
|
|
330
|
+
buffer.pointer = lineno - 1 # (->) pointer:mark
|
|
331
|
+
buffer.ensureLineMoreOnScreen(lineno - 1)
|
|
338
332
|
self.code = code
|
|
339
333
|
wx.CallAfter(_mark)
|
|
340
|
-
|
|
334
|
+
|
|
341
335
|
def on_debug_next(self, frame):
|
|
342
336
|
"""Called in preloop (cmdloop)."""
|
|
343
337
|
shell = self.interactive_shell
|
|
@@ -347,13 +341,13 @@ class Debugger(Pdb):
|
|
|
347
341
|
pos = self.__cpos
|
|
348
342
|
out = shell.GetTextRange(pos, shell.cpos)
|
|
349
343
|
if out.strip(' ') == self.prompt.strip(' ') and pos > shell.bol:
|
|
350
|
-
shell.cpos = pos
|
|
344
|
+
shell.cpos = pos # backward selection
|
|
351
345
|
shell.ReplaceSelection('')
|
|
352
346
|
shell.prompt()
|
|
353
347
|
shell.EnsureCaretVisible()
|
|
354
348
|
self.__cpos = shell.cpos
|
|
355
349
|
wx.CallAfter(_next)
|
|
356
|
-
|
|
350
|
+
|
|
357
351
|
def on_debug_end(self, frame):
|
|
358
352
|
"""Called after set_quit.
|
|
359
353
|
Note: self.busy -> True (until this stage)
|
|
@@ -365,28 +359,23 @@ class Debugger(Pdb):
|
|
|
365
359
|
|
|
366
360
|
## Note: Required to terminate the reader of threading pdb.
|
|
367
361
|
self.send_input('\n')
|
|
368
|
-
|
|
369
|
-
def _continue():
|
|
370
|
-
if wx.IsBusy():
|
|
371
|
-
wx.EndBusyCursor()
|
|
372
|
-
wx.CallAfter(_continue)
|
|
373
|
-
|
|
362
|
+
|
|
374
363
|
def on_trace_hook(self, frame):
|
|
375
364
|
"""Called when a breakppoint is reached."""
|
|
376
365
|
self.__hookpoint = None
|
|
377
|
-
self.interactive_shell.write('\n', -1)
|
|
366
|
+
self.interactive_shell.write('\n', -1) # move to eolc and insert LFD
|
|
378
367
|
self.message(where(frame.f_code), indent=0)
|
|
379
|
-
|
|
368
|
+
|
|
380
369
|
## --------------------------------
|
|
381
|
-
## Override Bdb methods
|
|
370
|
+
## Override Bdb methods.
|
|
382
371
|
## --------------------------------
|
|
383
|
-
|
|
372
|
+
|
|
384
373
|
def break_anywhere(self, frame):
|
|
385
374
|
"""Return False (override)
|
|
386
375
|
even if there is any breakpoint for frame's filename.
|
|
387
376
|
"""
|
|
388
377
|
return False
|
|
389
|
-
|
|
378
|
+
|
|
390
379
|
def dispatch_line(self, frame):
|
|
391
380
|
"""Invoke user function and return trace function for line event.
|
|
392
381
|
|
|
@@ -405,7 +394,7 @@ class Debugger(Pdb):
|
|
|
405
394
|
else:
|
|
406
395
|
return None
|
|
407
396
|
return Pdb.dispatch_line(self, frame)
|
|
408
|
-
|
|
397
|
+
|
|
409
398
|
def dispatch_call(self, frame, arg):
|
|
410
399
|
"""Invoke user function and return trace function for call event.
|
|
411
400
|
|
|
@@ -416,14 +405,14 @@ class Debugger(Pdb):
|
|
|
416
405
|
filename = frame.f_code.co_filename
|
|
417
406
|
lineno = frame.f_lineno
|
|
418
407
|
if target == filename:
|
|
419
|
-
if lineno <= line:
|
|
408
|
+
if lineno <= line: # continue to dispatch_line
|
|
420
409
|
return self.trace_dispatch
|
|
421
410
|
else:
|
|
422
411
|
return None
|
|
423
412
|
else:
|
|
424
413
|
return None
|
|
425
414
|
return Pdb.dispatch_call(self, frame, arg)
|
|
426
|
-
|
|
415
|
+
|
|
427
416
|
def dispatch_return(self, frame, arg):
|
|
428
417
|
"""Invoke user function and return trace function for return event.
|
|
429
418
|
|
|
@@ -432,7 +421,7 @@ class Debugger(Pdb):
|
|
|
432
421
|
if self.__hookpoint:
|
|
433
422
|
return None
|
|
434
423
|
return Pdb.dispatch_return(self, frame, arg)
|
|
435
|
-
|
|
424
|
+
|
|
436
425
|
def dispatch_exception(self, frame, arg):
|
|
437
426
|
"""Invoke user function and return trace function for exception event.
|
|
438
427
|
|
|
@@ -441,7 +430,7 @@ class Debugger(Pdb):
|
|
|
441
430
|
if self.__hookpoint:
|
|
442
431
|
return None
|
|
443
432
|
return Pdb.dispatch_exception(self, frame, arg)
|
|
444
|
-
|
|
433
|
+
|
|
445
434
|
def set_trace(self, frame=None):
|
|
446
435
|
if self.busy:
|
|
447
436
|
wx.MessageBox("Debugger is running.\n\n"
|
|
@@ -451,34 +440,34 @@ class Debugger(Pdb):
|
|
|
451
440
|
frame = inspect.currentframe().f_back
|
|
452
441
|
self.handler('debug_begin', frame)
|
|
453
442
|
Pdb.set_trace(self, frame)
|
|
454
|
-
|
|
443
|
+
|
|
455
444
|
def set_break(self, filename, lineno, *args, **kwargs):
|
|
456
445
|
self._markbp(lineno, 1)
|
|
457
446
|
return Pdb.set_break(self, filename, lineno, *args, **kwargs)
|
|
458
|
-
|
|
447
|
+
|
|
459
448
|
def set_quit(self):
|
|
460
449
|
try:
|
|
461
450
|
Pdb.set_quit(self)
|
|
462
451
|
finally:
|
|
463
|
-
if self.parent:
|
|
452
|
+
if self.parent: # Check if the parent is being deleted.
|
|
464
453
|
self.handler('debug_end', self.curframe)
|
|
465
|
-
|
|
454
|
+
|
|
466
455
|
## --------------------------------
|
|
467
|
-
## Override Pdb methods
|
|
456
|
+
## Override Pdb methods.
|
|
468
457
|
## --------------------------------
|
|
469
|
-
|
|
458
|
+
|
|
470
459
|
@echo
|
|
471
460
|
def print_stack_entry(self, frame_lineno, prompt_prefix=None):
|
|
472
461
|
"""Print the stack entry frame_lineno (frame, lineno).
|
|
473
462
|
|
|
474
463
|
(override) Change prompt_prefix.
|
|
475
|
-
Add pointer:
|
|
464
|
+
Add pointer:mark when step next or jump.
|
|
476
465
|
"""
|
|
477
466
|
if self.verbose:
|
|
478
467
|
Pdb.print_stack_entry(self, frame_lineno,
|
|
479
468
|
prompt_prefix or "\n{}-> ".format(self.indents))
|
|
480
469
|
self.handler('debug_mark', frame_lineno[0])
|
|
481
|
-
|
|
470
|
+
|
|
482
471
|
@echo
|
|
483
472
|
def user_call(self, frame, argument_list):
|
|
484
473
|
"""--Call--
|
|
@@ -490,13 +479,13 @@ class Debugger(Pdb):
|
|
|
490
479
|
self.message("> {}".format(where(frame)), indent=0)
|
|
491
480
|
self.indents += ' ' * 2
|
|
492
481
|
Pdb.user_call(self, frame, argument_list)
|
|
493
|
-
|
|
482
|
+
|
|
494
483
|
@echo
|
|
495
484
|
def user_line(self, frame):
|
|
496
485
|
"""--Next--
|
|
497
486
|
"""
|
|
498
487
|
Pdb.user_line(self, frame)
|
|
499
|
-
|
|
488
|
+
|
|
500
489
|
@echo
|
|
501
490
|
def user_return(self, frame, return_value):
|
|
502
491
|
"""--Return--
|
|
@@ -511,10 +500,10 @@ class Debugger(Pdb):
|
|
|
511
500
|
frame.f_locals['__return__'] = return_value
|
|
512
501
|
self.message('--Return--')
|
|
513
502
|
if len(self.indents) > 2:
|
|
514
|
-
self.indents = self.indents[:-2]
|
|
503
|
+
self.indents = self.indents[:-2] # remove ' '
|
|
515
504
|
self.interaction(frame, None)
|
|
516
505
|
## Pdb.user_return(self, frame, return_value)
|
|
517
|
-
|
|
506
|
+
|
|
518
507
|
@echo
|
|
519
508
|
def user_exception(self, frame, exc_info):
|
|
520
509
|
"""--Exception--
|
|
@@ -525,7 +514,7 @@ class Debugger(Pdb):
|
|
|
525
514
|
self._markbp(tb.tb_lineno, 2)
|
|
526
515
|
self.message(tb.tb_frame, indent=0)
|
|
527
516
|
Pdb.user_exception(self, frame, exc_info)
|
|
528
|
-
|
|
517
|
+
|
|
529
518
|
@echo
|
|
530
519
|
def bp_commands(self, frame):
|
|
531
520
|
"""--Break--
|
|
@@ -538,13 +527,13 @@ class Debugger(Pdb):
|
|
|
538
527
|
for lineno in breakpoints:
|
|
539
528
|
self._markbp(lineno, 1)
|
|
540
529
|
return Pdb.bp_commands(self, frame)
|
|
541
|
-
|
|
530
|
+
|
|
542
531
|
@echo
|
|
543
532
|
def preloop(self):
|
|
544
533
|
"""Hook method executed once when the cmdloop() method is called."""
|
|
545
534
|
Pdb.preloop(self)
|
|
546
535
|
self.handler('debug_next', self.curframe)
|
|
547
|
-
|
|
536
|
+
|
|
548
537
|
@echo
|
|
549
538
|
def postloop(self):
|
|
550
539
|
"""Hook method executed once when the cmdloop() method is about to return."""
|
mwx/wxwil.py
CHANGED
|
@@ -17,11 +17,11 @@ def _repr(value):
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class LocalsWatcher(wx.ListCtrl, ListCtrlAutoWidthMixin, CtrlInterface):
|
|
20
|
-
"""Locals info watcher
|
|
20
|
+
"""Locals info watcher.
|
|
21
21
|
|
|
22
22
|
Attributes:
|
|
23
|
-
parent
|
|
24
|
-
target
|
|
23
|
+
parent: shellframe
|
|
24
|
+
target: locals:dict to watch
|
|
25
25
|
"""
|
|
26
26
|
def __init__(self, parent, **kwargs):
|
|
27
27
|
wx.ListCtrl.__init__(self, parent,
|
|
@@ -34,8 +34,8 @@ class LocalsWatcher(wx.ListCtrl, ListCtrlAutoWidthMixin, CtrlInterface):
|
|
|
34
34
|
|
|
35
35
|
self.Font = wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
|
|
36
36
|
|
|
37
|
-
self.__dir = True
|
|
38
|
-
self.__items = []
|
|
37
|
+
self.__dir = True # sort direction
|
|
38
|
+
self.__items = [] # list of data:str
|
|
39
39
|
|
|
40
40
|
_alist = (
|
|
41
41
|
("key", 140),
|
|
@@ -59,13 +59,13 @@ class LocalsWatcher(wx.ListCtrl, ListCtrlAutoWidthMixin, CtrlInterface):
|
|
|
59
59
|
self.copy()
|
|
60
60
|
|
|
61
61
|
dispatcher.connect(receiver=self._update, signal='Interpreter.push')
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
def _update(self, *args, **kwargs):
|
|
64
64
|
if not self:
|
|
65
65
|
dispatcher.disconnect(receiver=self._update, signal='Interpreter.push')
|
|
66
66
|
return
|
|
67
67
|
self.update()
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
def watch(self, locals):
|
|
70
70
|
self.clear()
|
|
71
71
|
if not isinstance(locals, dict):
|
|
@@ -86,18 +86,18 @@ class LocalsWatcher(wx.ListCtrl, ListCtrlAutoWidthMixin, CtrlInterface):
|
|
|
86
86
|
self.blink(i)
|
|
87
87
|
finally:
|
|
88
88
|
self.Thaw()
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
def unwatch(self):
|
|
91
91
|
self.target = None
|
|
92
|
-
|
|
92
|
+
|
|
93
93
|
## --------------------------------
|
|
94
|
-
## Actions on list items
|
|
94
|
+
## Actions on list items.
|
|
95
95
|
## --------------------------------
|
|
96
|
-
|
|
96
|
+
|
|
97
97
|
def clear(self):
|
|
98
98
|
self.DeleteAllItems()
|
|
99
99
|
del self.__items[:]
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
def update(self):
|
|
102
102
|
if not self.target:
|
|
103
103
|
return
|
|
@@ -116,7 +116,7 @@ class LocalsWatcher(wx.ListCtrl, ListCtrlAutoWidthMixin, CtrlInterface):
|
|
|
116
116
|
if i is not None:
|
|
117
117
|
if data[i][1] == vstr:
|
|
118
118
|
continue
|
|
119
|
-
data[i][1] = vstr
|
|
119
|
+
data[i][1] = vstr # Update data to locals
|
|
120
120
|
else:
|
|
121
121
|
i = len(data)
|
|
122
122
|
item = [key, vstr]
|
|
@@ -125,7 +125,7 @@ class LocalsWatcher(wx.ListCtrl, ListCtrlAutoWidthMixin, CtrlInterface):
|
|
|
125
125
|
self.SetItem(i, 1, vstr)
|
|
126
126
|
self.blink(i)
|
|
127
127
|
self.EnsureVisible(i)
|
|
128
|
-
|
|
128
|
+
|
|
129
129
|
def blink(self, i):
|
|
130
130
|
if self.GetItemBackgroundColour(i) != wx.Colour('yellow'):
|
|
131
131
|
self.SetItemBackgroundColour(i, "yellow")
|
|
@@ -133,7 +133,7 @@ class LocalsWatcher(wx.ListCtrl, ListCtrlAutoWidthMixin, CtrlInterface):
|
|
|
133
133
|
if self and i < self.ItemCount:
|
|
134
134
|
self.SetItemBackgroundColour(i, 'white')
|
|
135
135
|
wx.CallAfter(wx.CallLater, 1000, _reset_color)
|
|
136
|
-
|
|
136
|
+
|
|
137
137
|
def copy(self):
|
|
138
138
|
if not self.SelectedItemCount:
|
|
139
139
|
return
|
|
@@ -143,8 +143,8 @@ class LocalsWatcher(wx.ListCtrl, ListCtrlAutoWidthMixin, CtrlInterface):
|
|
|
143
143
|
key, vstr = self.__items[i]
|
|
144
144
|
text += "{} = {}\n".format(key, vstr)
|
|
145
145
|
Clipboard.write(text)
|
|
146
|
-
|
|
147
|
-
def OnSortItems(self, evt):
|
|
146
|
+
|
|
147
|
+
def OnSortItems(self, evt): #<wx._controls.ListEvent>
|
|
148
148
|
n = self.ItemCount
|
|
149
149
|
if n < 2:
|
|
150
150
|
return
|
|
@@ -163,7 +163,7 @@ class LocalsWatcher(wx.ListCtrl, ListCtrlAutoWidthMixin, CtrlInterface):
|
|
|
163
163
|
self.Select(i, item in ls)
|
|
164
164
|
if item == fi:
|
|
165
165
|
self.Focus(i)
|
|
166
|
-
|
|
166
|
+
|
|
167
167
|
def OnContextMenu(self, evt):
|
|
168
168
|
Menu.Popup(self, [
|
|
169
169
|
(1, "Copy data", Icon('copy'),
|