mwxlib 0.80.1__py3-none-any.whl → 0.80.2__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.80.1"
7
+ __version__ = "0.80.2"
8
8
  __author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
9
9
 
10
10
  from functools import wraps, partial
@@ -1424,6 +1424,19 @@ class ShellFrame(MiniFrame):
1424
1424
  self.debugger.debug(obj, *args, **kwargs)
1425
1425
  finally:
1426
1426
  self.debugger.interactive_shell = shell
1427
+ elif isinstance(obj, str):
1428
+ try:
1429
+ shell = self.debugger.interactive_shell
1430
+ self.debugger.interactive_shell = self.current_shell
1431
+ self.debugger.editor = self.Log # set default logger
1432
+ filename = "<string>"
1433
+ buf = self.Log.find_buffer(filename)\
1434
+ or self.Log.create_new_buffer(filename)
1435
+ with buf.off_readonly():
1436
+ buf.Text = obj
1437
+ self.debugger.run(obj)
1438
+ finally:
1439
+ self.debugger.interactive_shell = shell
1427
1440
  elif hasattr(obj, '__dict__'):
1428
1441
  self.message("Building locals info list...")
1429
1442
  self.linfo.watch(obj.__dict__)
mwx/nutshell.py CHANGED
@@ -2700,8 +2700,8 @@ class Nautilus(Shell, EditorInterface):
2700
2700
 
2701
2701
  - quoteback : x`y --> y=x
2702
2702
  - pullback : x@y --> y(x)
2703
- - partial : x@(y1,...,yn) --> partial(y1,...,yn)(x)
2704
- - apropos : x.y?p --> apropos(x,y,...,p)
2703
+ - partial : x@(y1,,,yn) --> partial(y1,,,yn)(x)
2704
+ - apropos : x.y?p --> apropos(x,y,,,p)
2705
2705
 
2706
2706
  Note:
2707
2707
  This is called before run, execute, and original magic.
@@ -2727,22 +2727,26 @@ class Nautilus(Shell, EditorInterface):
2727
2727
  pass
2728
2728
 
2729
2729
  elif c == '@':
2730
- f = "{rhs}({lhs})"
2731
2730
  lhs = lhs.strip() or '_'
2732
2731
  rhs = _eats(rest, sep2).strip()
2732
+
2733
2733
  if rhs in ("debug", "profile", "timeit"):
2734
2734
  ## func(a,b,c) @debug --> func,a,b,c @debug
2735
- lhs = re.sub(r"([\w.]+)\((.*)\)", r"\1, \2", lhs, flags=re.S)
2736
- else:
2735
+ lhs = re.sub(r"(.*[\w\)\]])\s*\((.*)\)$",
2736
+ r"\1, \2", lhs, flags=re.S)
2737
+ ## obj[...] @debug --> obj.__getitem__, (...) @debug
2738
+ lhs = re.sub(r"(.*[\w\)\]])\s*\[(.*)\]$",
2739
+ r"\1.__getitem__, (\2)", lhs, flags=re.S)
2740
+ elif rhs.startswith('('):
2737
2741
  ## @(y1,,,yn) --> partial(y1,,,yn)
2738
2742
  rhs = re.sub(r"^\((.*)\)", r"partial(\1)", rhs, flags=re.S)
2739
- return self.magic_interpret([f.format(lhs=lhs, rhs=rhs)] + rest)
2743
+
2744
+ return self.magic_interpret([f"{rhs}({lhs})"] + rest)
2740
2745
 
2741
2746
  if c == '`':
2742
- f = "{rhs} = {lhs}"
2743
2747
  lhs = lhs.strip() or '_'
2744
2748
  rhs = _eats(rest, sep1).strip()
2745
- return self.magic_interpret([f.format(lhs=lhs, rhs=rhs)] + rest)
2749
+ return self.magic_interpret([f"{rhs} = {lhs}"] + rest)
2746
2750
 
2747
2751
  if c == '?':
2748
2752
  head, sep, hint = lhs.rpartition('.')
mwx/wxpdb.py CHANGED
@@ -235,6 +235,8 @@ class Debugger(Pdb):
235
235
  self.handler('abort')
236
236
 
237
237
  def debug(self, obj, *args, **kwargs):
238
+ """Debug a callable object.
239
+ """
238
240
  if not callable(obj):
239
241
  wx.MessageBox("Not a callable object.\n\n"
240
242
  "Unable to debug {!r}.".format(obj))
@@ -258,6 +260,31 @@ class Debugger(Pdb):
258
260
  self.set_quit()
259
261
  return
260
262
 
263
+ def run(self, cmd):
264
+ """Debug a statement executed via the exec() function.
265
+ """
266
+ if self.busy:
267
+ wx.MessageBox("Debugger is running.\n\n"
268
+ "Enter [q]uit to exit debug mode.")
269
+ return
270
+ self.unwatch()
271
+ globals = self.interactive_shell.globals
272
+ locals = self.interactive_shell.locals
273
+ if isinstance(cmd, str):
274
+ cmd = compile(cmd, "<string>", "exec")
275
+ try:
276
+ frame = inspect.currentframe().f_back
277
+ self.set_trace(frame)
278
+ exec(cmd, globals, locals)
279
+ except BdbQuit:
280
+ pass
281
+ except Exception as e:
282
+ ## Note: CallAfter to avoid crashing by a kill-focus event.
283
+ wx.CallAfter(wx.MessageBox,
284
+ "Debugger is closed.\n\n{}".format(e))
285
+ finally:
286
+ self.set_quit()
287
+
261
288
  ## --------------------------------
262
289
  ## Actions for handler
263
290
  ## --------------------------------
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mwxlib
3
- Version: 0.80.1
3
+ Version: 0.80.2
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=CxhKHOhig62F8p6GvP5gii-VvQtSjp9yWJpHvC_Kans,2592
2
2
  mwx/controls.py,sha256=d5ZRw21nXxV06QHV5Y9t85Lqm3pLZRoPS27YknC_H54,42455
3
- mwx/framework.py,sha256=CZlL9TYgWOFh5pOgxm5sxZPpMkzuiQPvnmu0zckoUmA,68726
3
+ mwx/framework.py,sha256=3wkSURTcq751o30D5nq2OSHnM08Ng4uwUnANVzRVxs4,69327
4
4
  mwx/graphman.py,sha256=2_0vEJB2hbIzeILufty6Dc_sCRg_3Abc0ZhXrfCkuo4,69226
5
5
  mwx/images.py,sha256=9e8X7OpJ6Z3fF3ez17P_qk2D1NMO10-lN8TCtulAqT0,46248
6
6
  mwx/matplot2.py,sha256=OnG33VYvNY9tPbTiUdhM1bibnMwx8Z91hq2Wv7az78s,36000
7
7
  mwx/matplot2g.py,sha256=yfF4r6juclU1I1k41lGb_VwxRmp0ktuD8az-wQ26MsE,67727
8
8
  mwx/matplot2lg.py,sha256=Dnz_U7K_QkPmsJd18WzZ6PkaTOtWu_IwOgkfEdJv4d0,27606
9
9
  mwx/mgplt.py,sha256=49_wpFZUEKErQmtobqrlNKDjWlAsdLft-izlqSyGPD0,6878
10
- mwx/nutshell.py,sha256=D1gM4bivte8GWgpOhXvSZwd6ZUVucsAU_tQfCu0laL8,133573
10
+ mwx/nutshell.py,sha256=qhgrxO6UpOgxODtG1nppbrZWNFsd9Mg4Y6a0EWl5Xas,133784
11
11
  mwx/utilus.py,sha256=3VaUX_hclVLYixOyDC-4gxxug9_4kMzCTQcDuHs3REA,34863
12
12
  mwx/wxmon.py,sha256=Odmh13Ek4oJo9V5uFCTemoWlsPyZt4ITTmYZiKl_BKI,11405
13
- mwx/wxpdb.py,sha256=FoEgaSeKnKz3JHYnpddMpPelazXIbuvV15XVkBZ6c8k,18823
13
+ mwx/wxpdb.py,sha256=-_rDNxk3S3z1PgDZ6AAhKksFp8wJL3NBKDxfOZ74E3c,19790
14
14
  mwx/wxwil.py,sha256=BUfEF0Nc1E-mVC3Vdz6k1E-2s5J0PO6qEzRQ6lfyePI,5246
15
15
  mwx/wxwit.py,sha256=M_jRGJOZge2B4Cq1OsAHqnGjeg56UI-v1BolDybPR-o,7246
16
16
  mwx/py/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  mwx/py/filling.py,sha256=NnQnfUVol-Nz4QYZUKFIyRX-Yxp54m5n54Yxza3Iwho,16655
18
- mwxlib-0.80.1.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
19
- mwxlib-0.80.1.dist-info/METADATA,sha256=YXvrpndDe6OyVAnL5iCbeoahNVq1yZXwNkretd8OTco,1995
20
- mwxlib-0.80.1.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
21
- mwxlib-0.80.1.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
22
- mwxlib-0.80.1.dist-info/RECORD,,
18
+ mwxlib-0.80.2.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
19
+ mwxlib-0.80.2.dist-info/METADATA,sha256=TEZNsDZwMDlNd_kSeAUCSHbNdKm0rY_kVAP8kW9dghM,1995
20
+ mwxlib-0.80.2.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
21
+ mwxlib-0.80.2.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
22
+ mwxlib-0.80.2.dist-info/RECORD,,