PrEditor 1.0.0__py3-none-any.whl → 1.1.0__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 PrEditor might be problematic. Click here for more details.

preditor/config.py CHANGED
@@ -48,6 +48,7 @@ class PreditorConfig:
48
48
  self._name = None
49
49
  self._logging = False
50
50
  self._headless_callback = None
51
+ self._on_create_callback = None
51
52
  self._parent_callback = None
52
53
  self._error_dialog_class = True
53
54
  self._excepthooks = []
@@ -63,6 +64,7 @@ class PreditorConfig:
63
64
  f"{' ' * indent}logging: {self.logging}",
64
65
  f"{' ' * indent}headless_callback: {self.headless_callback!r}",
65
66
  f"{' ' * indent}parent_callback: {self.parent_callback!r}",
67
+ f"{' ' * indent}on_create_callback: {self.on_create_callback!r}",
66
68
  ]
67
69
  return '\n'.join(ret)
68
70
 
@@ -233,6 +235,20 @@ class PreditorConfig:
233
235
  # If the core name was changed attempt to update the logging config.
234
236
  self.update_logging()
235
237
 
238
+ @property
239
+ def on_create_callback(self):
240
+ """A pointer to a method that is called on LoggerWindow instance create.
241
+
242
+ This callback accepts the instance and can be used to customize the
243
+ LoggerWindow instance when it is first created.
244
+ """
245
+ return self._on_create_callback
246
+
247
+ @on_create_callback.setter
248
+ @set_if_unlocked()
249
+ def on_create_callback(self, cb):
250
+ self._on_create_callback = cb
251
+
236
252
  @property
237
253
  def parent_callback(self):
238
254
  """A pointer to a method that is called by `self.root_window`.
preditor/excepthooks.py CHANGED
@@ -16,9 +16,7 @@ class PreditorExceptHook(object):
16
16
  `sys.excepthook` is called due to an raised exception.
17
17
 
18
18
  If `config.excepthook` is empty when installing this class, it will
19
- automatically add the `call_base_excepthook` and `ask_to_show_logger` methods.
20
- This enables showing the excepthook in parent streams and prompting the user
21
- to show PrEditor when an error happens. You can disable this by adding `None`
19
+ automatically add `default_excepthooks`. You can disable this by adding `None`
22
20
  to the list before this class is initialized.
23
21
  """
24
22
 
@@ -27,8 +25,7 @@ class PreditorExceptHook(object):
27
25
 
28
26
  # Add the default excepthooks
29
27
  if not config.excepthooks and config.excepthooks != [None]:
30
- config.excepthooks.append(self.call_base_excepthook)
31
- config.excepthooks.append(self.ask_to_show_logger)
28
+ config.excepthooks.extend(self.default_excepthooks())
32
29
 
33
30
  def __call__(self, *exc_info):
34
31
  """Run when an exception is raised and calls all `config.excepthooks`."""
@@ -40,6 +37,18 @@ class PreditorExceptHook(object):
40
37
  # Clear any ErrorReports that were generated by this exception handling
41
38
  ErrorReport.clearReports()
42
39
 
40
+ def default_excepthooks(self):
41
+ """Returns default excepthooks handlers.
42
+
43
+ This includes the `call_base_excepthook` and `ask_to_show_logger` methods.
44
+ They enables showing the excepthook in parent streams and prompting the user
45
+ to show PrEditor when an error happens.
46
+ """
47
+ return [
48
+ self.call_base_excepthook,
49
+ self.ask_to_show_logger,
50
+ ]
51
+
43
52
  def call_base_excepthook(self, *exc_info):
44
53
  """Process `base_excepthook` supplied during object instantiation.
45
54
 
@@ -2,6 +2,7 @@ from __future__ import absolute_import, print_function
2
2
 
3
3
  import itertools
4
4
  import json
5
+ import logging
5
6
  import os
6
7
  import re
7
8
  import sys
@@ -27,7 +28,7 @@ from Qt.QtWidgets import (
27
28
  from .. import (
28
29
  DEFAULT_CORE_NAME,
29
30
  about_preditor,
30
- core,
31
+ config,
31
32
  debug,
32
33
  get_core_name,
33
34
  osystem,
@@ -46,6 +47,8 @@ from .level_buttons import LoggingLevelButton
46
47
  from .set_text_editor_path_dialog import SetTextEditorPathDialog
47
48
  from .status_label import StatusLabel
48
49
 
50
+ logger = logging.getLogger(__name__)
51
+
49
52
 
50
53
  class WorkboxPages:
51
54
  """Nice names for the uiWorkboxSTACK indexes."""
@@ -1335,18 +1338,16 @@ class LoggerWindow(Window):
1335
1338
  parent, name=name, run_workbox=run_workbox, standalone=standalone
1336
1339
  )
1337
1340
 
1338
- # RV has a Unique window structure. It makes more sense to not parent a
1339
- # singleton window than to parent it to a specific top level window.
1340
- if core.objectName() == 'rv':
1341
- inst.setParent(None)
1342
- inst.setAttribute(Qt.WA_QuitOnClose, False)
1343
-
1344
1341
  # protect the memory
1345
1342
  inst.setAttribute(Qt.WA_DeleteOnClose, False)
1346
1343
 
1347
1344
  # cache the instance
1348
1345
  LoggerWindow._instance = inst
1349
1346
 
1347
+ # Allow customization when the instance is first created.
1348
+ if config.on_create_callback:
1349
+ config.on_create_callback(inst)
1350
+
1350
1351
  return LoggerWindow._instance
1351
1352
 
1352
1353
  def installLogToFile(self):
@@ -1380,6 +1381,16 @@ class LoggerWindow(Window):
1380
1381
  bool: If a shutdown was required
1381
1382
  """
1382
1383
  if cls._instance:
1383
- cls._instance.shutdown()
1384
+ try:
1385
+ cls._instance.shutdown()
1386
+ except RuntimeError as error:
1387
+ # If called after the host Qt application has been closed then
1388
+ # the instance has been deleted and we can't save preferences
1389
+ # without getting a RuntimeError about C/C++ being deleted.
1390
+ logger.warning(
1391
+ f"instance_shutdown failed PrEditor prefs likely not saved: {error}"
1392
+ )
1393
+ return False
1394
+
1384
1395
  return True
1385
1396
  return False
preditor/version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '1.0.0'
21
- __version_tuple__ = version_tuple = (1, 0, 0)
20
+ __version__ = version = '1.1.0'
21
+ __version_tuple__ = version_tuple = (1, 1, 0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PrEditor
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: A python REPL and Editor and console based on Qt.
5
5
  Author-email: Blur Studio <opensource@blur.com>
6
6
  License: LGPL-3.0
@@ -2,18 +2,18 @@ preditor/__init__.py,sha256=OJO0Gsh74_OA6lS_q3tgIh2zLS8lr7fzTk0kyCqnz2k,12163
2
2
  preditor/__main__.py,sha256=boRVSmxX6eF8EkzbePtCZbzdcaPseqVae4RPPLp3U1A,449
3
3
  preditor/about_module.py,sha256=rz1B3vL93AfJsAk_dnqSsDXcBYZJUf4lAdwUYAfwMwU,5085
4
4
  preditor/cli.py,sha256=kyVr0V43KYSMLIEWXH54CA0ByFmPcpbFF-8cli6PVow,5300
5
- preditor/config.py,sha256=e4UzXh9bIz4Yna2_il5MCx9_uzFrhy9pQK82vMpyuAo,11319
5
+ preditor/config.py,sha256=DTDqJ8cVnbvAE8IytAREMV7HJS2b3DLH1jtFIkdTo8c,11883
6
6
  preditor/contexts.py,sha256=xxRbOFORsvlG___EuSiKuT1aiKJvnkFojFZFZE0HPNk,5147
7
7
  preditor/debug.py,sha256=lXSdjWjThAuie8WC-B6wZHppDxsBeftJs-LaAMr5l48,4535
8
8
  preditor/enum.py,sha256=snG5V259dH9SI1kwBqZeZdhat36F1iAmIjYErosnDUg,23489
9
- preditor/excepthooks.py,sha256=cdHyd_eyQaEHhVl4srHbEfKC3NtLlb8AI2KBEdK_PUg,4934
9
+ preditor/excepthooks.py,sha256=DUolMjQxOIqX9czYQfQ4WqSjMIH5VP9ZcaFoI0LRky4,5126
10
10
  preditor/logging_config.py,sha256=aCqBhnHhcTigpR7neVEPbx4Vc_3ADpiqaBQ7uOd4qRQ,1462
11
11
  preditor/osystem.py,sha256=vRr-WaIzYEO38tJeyHMOlAyrvGaWGBuiyaPx0X9JfZ4,13682
12
12
  preditor/plugins.py,sha256=RAeyvdZxQsZY313ae5aAhahqpjuhaXJzDxPyLcR-09U,4401
13
13
  preditor/prefs.py,sha256=BPtSsdv2yuiRpIaqEml9fxlVYKHNfqQ77hp5YIQRDBg,2172
14
14
  preditor/settings.py,sha256=DV9_DbJorEnhdIvW15E7h7PswlQUsy0UlA8bXUYN0og,2206
15
15
  preditor/streamhandler_helper.py,sha256=kiU6T9WqJ3JKTTKCa7IUU8brwK7zO5UUpEzLhEfKe44,1788
16
- preditor/version.py,sha256=fo5PXsZuloQZu3LdpIFTUAXvJmY2L9N5sNGe2tvdU98,511
16
+ preditor/version.py,sha256=UNO7UaKPam6Zugzw6NMt_RQBnRzrv9GVeKUjWt-tl6I,511
17
17
  preditor/weakref.py,sha256=b--KomFAHcMWr3DEAIN2j3XxRhjDWKw0WABXyn1nxDg,12177
18
18
  preditor/cores/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  preditor/cores/core.py,sha256=mdVXlEPDh8kIdOpMDqi8P1VaqfVvyu5cXBq_toONcaM,586
@@ -34,7 +34,7 @@ preditor/gui/find_files.py,sha256=8_b0oQgL6u8U2FqpR2RzMChME9eYdJq3c3bgXXDeceY,42
34
34
  preditor/gui/level_buttons.py,sha256=YVvdpXItbFAGl_vYTBcYvOKNQmmEaHRY63pX30WHBbk,11728
35
35
  preditor/gui/logger_window_handler.py,sha256=43-DxzuNJq6UV6Ofc4TKRt179Sf5AxDkVDGrtq_Knok,1571
36
36
  preditor/gui/logger_window_plugin.py,sha256=x6mTuS6gmeMZtV0UIXHXIif1_B5oKVbJhuIBaW0BFVs,1210
37
- preditor/gui/loggerwindow.py,sha256=BRay-9ex8vWiutsxRHYs9lyWVCX_aFCdc3Z8NQvccmM,53510
37
+ preditor/gui/loggerwindow.py,sha256=kiADRLw8yzr5qyFpHfFbC2uEFu2Zz5YHnB8Yf7p-gj0,53886
38
38
  preditor/gui/newtabwidget.py,sha256=5aCWn9xAl5h1oZACqVuEsOAbzKTS2RegrLI41gROC8A,1971
39
39
  preditor/gui/set_text_editor_path_dialog.py,sha256=wzWAUgzGrsWbhcxeHjGlctuFVPXtYyxwnigAeUeeb5o,2247
40
40
  preditor/gui/status_label.py,sha256=SlNRmPc28S4E2OFVmErv0DmZstk4011Q_7uLp43SF0A,3320
@@ -150,9 +150,9 @@ preditor/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
150
150
  preditor/utils/cute.py,sha256=LfF8gXMAkkQAdo4mm6J9aVkDLwWZbE6prQ0moDbtCys,1045
151
151
  preditor/utils/stylesheets.py,sha256=EVWZNq3WnaRiyUPoYMKQo_dLEwbRyKu26b03I1JDA-s,1622
152
152
  preditor/utils/text_search.py,sha256=21kuSDTpLIPUcriB81WP1kWfzuDBuP13ZtHUtypP5jE,14218
153
- preditor-1.0.0.dist-info/licenses/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
154
- preditor-1.0.0.dist-info/METADATA,sha256=SYwQuPDvd7X8sqbtIaItv8HYpfKg2QrMbCJJy6csu3c,9948
155
- preditor-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
156
- preditor-1.0.0.dist-info/entry_points.txt,sha256=mpe0HFD_oIEBNPTJNyUEbmMV6Ivrp4EuYyZ34C5d_PU,519
157
- preditor-1.0.0.dist-info/top_level.txt,sha256=iX1_mrUOky_BQr2oG0l_MbEUYF6idyjiWSzu9z3irIw,9
158
- preditor-1.0.0.dist-info/RECORD,,
153
+ preditor-1.1.0.dist-info/licenses/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
154
+ preditor-1.1.0.dist-info/METADATA,sha256=maaheBBs8muvTMHa_8vUvYtGwS9uSmNvPET40yphdOU,9948
155
+ preditor-1.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
156
+ preditor-1.1.0.dist-info/entry_points.txt,sha256=mpe0HFD_oIEBNPTJNyUEbmMV6Ivrp4EuYyZ34C5d_PU,519
157
+ preditor-1.1.0.dist-info/top_level.txt,sha256=iX1_mrUOky_BQr2oG0l_MbEUYF6idyjiWSzu9z3irIw,9
158
+ preditor-1.1.0.dist-info/RECORD,,