mwxlib 1.5.11__py3-none-any.whl → 1.5.12__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
@@ -1,7 +1,7 @@
1
1
  #! python3
2
2
  """mwxlib framework.
3
3
  """
4
- __version__ = "1.5.11"
4
+ __version__ = "1.5.12"
5
5
  __author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
6
6
 
7
7
  from contextlib import contextmanager
mwx/graphman.py CHANGED
@@ -569,8 +569,7 @@ class Graph(GraphPlot):
569
569
  del self.region
570
570
 
571
571
  def hide_layers(self):
572
- for name in self.parent.plugins:
573
- plug = self.parent.get_plug(name)
572
+ for plug in self.parent.get_all_plugs():
574
573
  for art in plug.Arts:
575
574
  art.set_visible(0)
576
575
  self.remove_markups()
@@ -881,8 +880,7 @@ class Frame(mwx.Frame):
881
880
  elif ret == wx.ID_CANCEL:
882
881
  evt.Veto()
883
882
  return
884
- n = sum(bool(plug.thread and plug.thread.active)
885
- for plug in (self.get_plug(name) for name in self.plugins))
883
+ n = sum(bool(plug.thread and plug.thread.active) for plug in self.get_all_plugs())
886
884
  if n:
887
885
  s = 's' if n > 1 else ''
888
886
  if wx.MessageBox( # Confirm closing the thread.
@@ -1050,6 +1048,10 @@ class Frame(mwx.Frame):
1050
1048
  elif isinstance(name, LayerInterface):
1051
1049
  return name
1052
1050
 
1051
+ def get_all_plugs(self):
1052
+ for name, module in self.plugins.items():
1053
+ yield module.__plug__
1054
+
1053
1055
  def load_plug(self, root, force=False, session=None, show=False,
1054
1056
  dock=0, floating_pos=None, floating_size=None,
1055
1057
  **kwargs):
@@ -1079,7 +1081,8 @@ class Frame(mwx.Frame):
1079
1081
  floating_size=floating_size)
1080
1082
 
1081
1083
  if inspect.ismodule(root):
1082
- name = root.__file__ # @TODO root.__name__
1084
+ name = root.__file__
1085
+ ## name = root.__name__ @TODO: Change root module name
1083
1086
  elif inspect.isclass(root):
1084
1087
  name = inspect.getsourcefile(root)
1085
1088
  else:
@@ -1088,17 +1091,23 @@ class Frame(mwx.Frame):
1088
1091
  if name.endswith(".py"):
1089
1092
  name = name[:-3]
1090
1093
 
1091
- ## Check if the plug is already loaded or needs to be reloaded.
1092
- plug = self.get_plug(name)
1093
- if plug and not force:
1094
- self.update_pane(name, **props)
1095
- self.show_pane(name, show)
1096
- try:
1097
- if session:
1098
- plug.load_session(session)
1099
- except Exception:
1100
- traceback.print_exc() # Failed to load the plug session.
1101
- return None
1094
+ if not force:
1095
+ ## 文字列参照 (root:str) による重複ロードを避ける @TODO: Change root module name
1096
+ ## for mod in self.plugins.values():
1097
+ ## if root == mod.__file__:
1098
+ ## print(f"- {name!r} is already loaded as {mod.__name__!r}.")
1099
+ ## return None
1100
+ ## Check if the named plug is already loaded.
1101
+ plug = self.get_plug(name)
1102
+ if plug:
1103
+ self.update_pane(name, **props)
1104
+ self.show_pane(name, show)
1105
+ try:
1106
+ if session:
1107
+ plug.load_session(session)
1108
+ except Exception:
1109
+ traceback.print_exc() # Failed to load the plug session.
1110
+ return None
1102
1111
 
1103
1112
  ## Update the include-path to load the module correctly.
1104
1113
  if os.path.isdir(dirname_):
@@ -1109,7 +1118,7 @@ class Frame(mwx.Frame):
1109
1118
  print(f"- No such directory {dirname_!r}.")
1110
1119
  return False
1111
1120
 
1112
- ## Load or reload the root module, and check whether it contains a class named `Plugin`.
1121
+ ## Load or reload the module, and check whether it contains a class named `Plugin`.
1113
1122
  try:
1114
1123
  if name in sys.modules:
1115
1124
  module = reload(sys.modules[name])
@@ -1174,12 +1183,6 @@ class Frame(mwx.Frame):
1174
1183
  style=wx.ICON_ERROR)
1175
1184
  return False
1176
1185
 
1177
- ## Add to the list after the plug is created successfully.
1178
- self.plugins[name] = module
1179
-
1180
- ## Set reference of a plug (one module, one plugin).
1181
- module.__plug__ = plug
1182
-
1183
1186
  ## Create pane or notebook pane.
1184
1187
  caption = plug.caption
1185
1188
  if not isinstance(caption, str):
@@ -1208,6 +1211,12 @@ class Frame(mwx.Frame):
1208
1211
  .Name(name).Caption(caption)
1209
1212
  .FloatingSize(size).MinSize(size).Show(0))
1210
1213
 
1214
+ ## Add to the list after the plug is created successfully.
1215
+ self.plugins[name] = module
1216
+
1217
+ ## Set reference of a plug (one module, one plugin).
1218
+ module.__plug__ = plug
1219
+
1211
1220
  ## Set winow.Name for inspection.
1212
1221
  plug.Name = name
1213
1222
 
@@ -1281,9 +1290,6 @@ class Frame(mwx.Frame):
1281
1290
  if not plug:
1282
1291
  print(f"- {name!r} is not listed in plugins.")
1283
1292
  return
1284
- if not plug.reloadable:
1285
- print(f"- {name!r} is not reloadable.")
1286
- return
1287
1293
 
1288
1294
  session = {}
1289
1295
  try:
@@ -1326,8 +1332,7 @@ class Frame(mwx.Frame):
1326
1332
 
1327
1333
  def Quit(self, evt=None):
1328
1334
  """Stop all Layer threads."""
1329
- for name in self.plugins:
1330
- plug = self.get_plug(name)
1335
+ for plug in self.get_all_plugs():
1331
1336
  thread = plug.thread # Note: thread can be None or shared.
1332
1337
  if thread and thread.active:
1333
1338
  ## thread.active = 0
mwx/utilus.py CHANGED
@@ -200,8 +200,12 @@ def typename(obj, docp=False, qualp=True):
200
200
  return pydoc.describe(obj) # atom -> short description
201
201
 
202
202
  modname = getattr(obj, '__module__', None)
203
- if modname and modname != "__main__" and not modname.startswith('mwx'):
204
- name = modname + ('.' if qualp else '..') + name
203
+ if modname:
204
+ if qualp:
205
+ name = modname + '.' + name
206
+ else:
207
+ if not modname.startswith(("__main__", "mwx")):
208
+ name = modname + '..' + name
205
209
 
206
210
  if docp and callable(obj) and obj.__doc__:
207
211
  name += "<{!r}>".format(obj.__doc__.splitlines()[0]) # concat the first doc line
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mwxlib
3
- Version: 1.5.11
3
+ Version: 1.5.12
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
@@ -1,8 +1,8 @@
1
1
  mwx/__init__.py,sha256=pS7ZG8QKRypiFFiaWAq_opBB6I_1viZ0zUMk2TbjzE0,667
2
2
  mwx/bookshelf.py,sha256=yW17nMNPXKHM7LLXLpr9DaRhyFHz_OBAZ_DsuEK2QzA,8387
3
3
  mwx/controls.py,sha256=Mpzpp2eWyS_X7RjxTJay1-Fldchk-x-rUBpUhHSG-5w,49924
4
- mwx/framework.py,sha256=LRy4HZqH_JdGhVzKnfq9LxEyF24CDmzaQRzyJ5P53Us,77574
5
- mwx/graphman.py,sha256=hixEmn8YAbmVLYjB_XRpyddKytlw8UJH32jm-fA1EKU,69601
4
+ mwx/framework.py,sha256=XFzMG6Jah0hROirGBGjmZHsv12986GV2-bjT4sl0D5w,77574
5
+ mwx/graphman.py,sha256=AjXd8Hyb-lCEkPuCz1C19aEi6dnt3DW8N0b89cVYITU,69905
6
6
  mwx/images.py,sha256=Kkfy9QI_hMtwShSjUS4-ZpC_EkVuah_XhpBOR4wAKkM,49792
7
7
  mwx/matplot2.py,sha256=5Z-m9KXtSXpzBQs3swqPbfl_mfVdDoPaWKqpiepfau8,33019
8
8
  mwx/matplot2g.py,sha256=hLBYWjXPc2jgtKPTQWCdieIegQvS4jjUUaedV4qDLoE,65255
@@ -10,7 +10,7 @@ mwx/matplot2lg.py,sha256=fpxOX18vonUTpA_nAr-wBhQ_2YNsL_nfxdCDliuP1sU,27430
10
10
  mwx/mgplt.py,sha256=SVUJ0ls4gC9xulbWxK2qqmDxf0uBCflvwoPkxoF5s3M,5566
11
11
  mwx/nutshell.py,sha256=CX-NK3kOEi3JHhjKh39R2_m1po1SvMxraaDk2xt6q-Y,147617
12
12
  mwx/testsuite.py,sha256=0Q_n_XOOsZ8lsLWUkuO8QW00hts9wEQfnUKMpf0BAyU,1235
13
- mwx/utilus.py,sha256=YVU-2aR9_22-clA0OCFKfmW0c49uhNWdbQaNXxNKXxA,38964
13
+ mwx/utilus.py,sha256=dsJ_wsEjqm-B75It-lwVCAiCPyPXZerngm_6TCUEmRU,39028
14
14
  mwx/wxmon.py,sha256=NIksW_CZv7Kw4dod8tWVwakO4iJuvE8hJSAcjkYfLaE,12800
15
15
  mwx/wxpdb.py,sha256=kKzEGivjoZ9zGcB3ttYsAym4putyilmXZXj-5CGaivQ,18813
16
16
  mwx/wxwil.py,sha256=hhyB1lPrF9ixeObxCOKQv0Theu-B-kpJg_yVU3EGSNg,5406
@@ -22,7 +22,7 @@ mwx/plugins/frame_listview.py,sha256=yd2NCgspqGfTNhj1wxuW8r1zapIm7vNzVX2iytk8CDM
22
22
  mwx/plugins/line_profile.py,sha256=zzm6_7lnAnNepLbh07ordp3nRWDFQJtu719ZVjrVf8s,819
23
23
  mwx/py/__init__.py,sha256=xykgfOytOwNuvXsfkLoumFZSTN-iBsHOjczYXngjmUE,12
24
24
  mwx/py/filling.py,sha256=fumUG1F5M9TL-Dfqni4G85uk7TmvnUunTbdcPDV0vfo,16857
25
- mwxlib-1.5.11.dist-info/METADATA,sha256=p669CmL2U7lNRmxUD2QMu286bsTCCQeOMUN990PNpqU,7382
26
- mwxlib-1.5.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
- mwxlib-1.5.11.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
28
- mwxlib-1.5.11.dist-info/RECORD,,
25
+ mwxlib-1.5.12.dist-info/METADATA,sha256=h77mRadmYbztrngMyjSysNdiM9fGxuQcbIN9zCpRpcY,7382
26
+ mwxlib-1.5.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
+ mwxlib-1.5.12.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
28
+ mwxlib-1.5.12.dist-info/RECORD,,