bec-widgets 0.76.0__py3-none-any.whl → 0.76.1__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.
CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v0.76.1 (2024-06-29)
4
+
5
+ ### Fix
6
+
7
+ * fix(plugins): fixes and tests for auto-gen plugins ([`c42511d`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/c42511dd44cc13577e108a6cef3166376e594f54))
8
+
3
9
  ## v0.76.0 (2024-06-28)
4
10
 
5
11
  ### Feature
@@ -124,10 +130,6 @@
124
130
 
125
131
  ## v0.71.0 (2024-06-23)
126
132
 
127
- ### Feature
128
-
129
- * feat(scan_group_box): scan box for args and kwargs separated from ScanControlGUI code ([`d8cf441`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/d8cf44134c30063e586771f9068947fef7a306d1))
130
-
131
133
  ### Fix
132
134
 
133
135
  * fix(cleanup): cleanup added to device_input widgets and scan_control ([`8badb6a`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/8badb6adc1d003dbf0b2b1a800c34821f3fc9aa3))
@@ -140,8 +142,6 @@
140
142
 
141
143
  * fix(scan_control): only scans with defined gui_config are allowed ([`6dff187`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/6dff1879c4178df0f8ebfd35101acdebb028d572))
142
144
 
143
- * fix(WidgetIO): find handlers within base classes ([`ca85638`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/ca856384f380dabf28d43f1cd48511af784c035b))
144
-
145
145
  ### Test
146
146
 
147
147
  * test(scan_control): tests added ([`56e74a0`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/56e74a0e7da72d18e89bc30d1896dbf9ef97cd6b))
PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bec_widgets
3
- Version: 0.76.0
3
+ Version: 0.76.1
4
4
  Summary: BEC Widgets
5
5
  Project-URL: Bug Tracker, https://gitlab.psi.ch/bec/bec_widgets/issues
6
6
  Project-URL: Homepage, https://gitlab.psi.ch/bec/bec_widgets
@@ -47,13 +47,12 @@ class DesignerPluginGenerator:
47
47
  def __init__(self, widget: type):
48
48
  self._excluded = False
49
49
  self.widget = widget
50
+ self.info = DesignerPluginInfo(widget)
50
51
  if widget.__name__ in EXCLUDED_PLUGINS:
51
52
 
52
53
  self._excluded = True
53
54
  return
54
55
 
55
- self.info = DesignerPluginInfo(widget)
56
-
57
56
  self.templates = {}
58
57
  self.template_path = os.path.join(
59
58
  os.path.dirname(os.path.abspath(__file__)), "plugin_templates"
@@ -75,7 +74,7 @@ class DesignerPluginGenerator:
75
74
 
76
75
  # Check if the widget class has parent as the first argument. This is a strict requirement of Qt!
77
76
  signature = list(inspect.signature(self.widget.__init__).parameters.values())
78
- if signature[1].name != "parent":
77
+ if len(signature) == 1 or signature[1].name != "parent":
79
78
  raise ValueError(
80
79
  f"Widget class {self.widget.__name__} must have parent as the first argument."
81
80
  )
@@ -89,20 +88,22 @@ class DesignerPluginGenerator:
89
88
  # Check if the widget class calls the super constructor with parent argument
90
89
  init_source = inspect.getsource(self.widget.__init__)
91
90
  cls_init_found = (
92
- bool(init_source.find(f"{base_cls[0].__name__}.__init__(self, parent=parent"))
93
- or bool(init_source.find(f"{base_cls[0].__name__}.__init__(self, parent)"))
94
- or bool(init_source.find(f"{base_cls[0].__name__}.__init__(self, parent,"))
91
+ bool(init_source.find(f"{base_cls[0].__name__}.__init__(self, parent=parent") > 0)
92
+ or bool(init_source.find(f"{base_cls[0].__name__}.__init__(self, parent)") > 0)
93
+ or bool(init_source.find(f"{base_cls[0].__name__}.__init__(self, parent,") > 0)
95
94
  )
96
95
  super_init_found = (
97
- bool(init_source.find(f"super({self.widget.__name__}, self).__init__(parent=parent"))
98
- or bool(init_source.find(f"super({self.widget.__name__}, self).__init__(parent,"))
99
- or bool(init_source.find(f"super({self.widget.__name__}, self).__init__(parent)"))
96
+ bool(
97
+ init_source.find(f"super({base_cls[0].__name__}, self).__init__(parent=parent") > 0
98
+ )
99
+ or bool(init_source.find(f"super({base_cls[0].__name__}, self).__init__(parent,") > 0)
100
+ or bool(init_source.find(f"super({base_cls[0].__name__}, self).__init__(parent)") > 0)
100
101
  )
101
- if issubclass(self.widget.__bases__[0], QObject) and super_init_found == -1:
102
+ if issubclass(self.widget.__bases__[0], QObject) and not super_init_found:
102
103
  super_init_found = (
103
- bool(init_source.find("super().__init__(parent=parent"))
104
- or bool(init_source.find("super().__init__(parent,"))
105
- or bool(init_source.find("super().__init__(parent)"))
104
+ bool(init_source.find("super().__init__(parent=parent") > 0)
105
+ or bool(init_source.find("super().__init__(parent,") > 0)
106
+ or bool(init_source.find("super().__init__(parent)") > 0)
106
107
  )
107
108
 
108
109
  if not cls_init_found and not super_init_found:
@@ -139,7 +140,7 @@ class DesignerPluginGenerator:
139
140
  self.templates[file.split(".")[0]] = f.read()
140
141
 
141
142
 
142
- if __name__ == "__main__":
143
+ if __name__ == "__main__": # pragma: no cover
143
144
  # from bec_widgets.widgets.bec_queue.bec_queue import BECQueue
144
145
  from bec_widgets.widgets.dock import BECDockArea
145
146
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bec_widgets
3
- Version: 0.76.0
3
+ Version: 0.76.1
4
4
  Summary: BEC Widgets
5
5
  Project-URL: Bug Tracker, https://gitlab.psi.ch/bec/bec_widgets/issues
6
6
  Project-URL: Homepage, https://gitlab.psi.ch/bec/bec_widgets
@@ -2,11 +2,11 @@
2
2
  .gitlab-ci.yml,sha256=RnYDz4zKXjlqltTryprlB1s5vLXxI2-seW-Vb70NNF0,8162
3
3
  .pylintrc,sha256=OstrgmEyP0smNFBKoIN5_26-UmNZgMHnbjvAWX0UrLs,18535
4
4
  .readthedocs.yaml,sha256=aSOc277LqXcsTI6lgvm_JY80lMlr69GbPKgivua2cS0,603
5
- CHANGELOG.md,sha256=f7NEQ2MAF9BEMk8iD2jAixb0HA5WGAKthPBShjyIzz8,6859
5
+ CHANGELOG.md,sha256=ekeMC81fhBxY6irOaVb51CGYg1cb_im8AiO4lyZHckc,6690
6
6
  LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
7
- PKG-INFO,sha256=Zi2GSe-npT55crEiQspELhVGcx_gfEiW_E4Duz9AS-0,1407
7
+ PKG-INFO,sha256=-U5bxfflX9Bl1WUPGgROel3NEW1D9GQROCFx6yvARMo,1407
8
8
  README.md,sha256=y4jB6wvArS7N8_iTbKWnSM_oRAqLA2GqgzUR-FMh5sU,2645
9
- pyproject.toml,sha256=p_NQqe-hmuikpj0AVASlTPa-z4L6zsho2G0fQXv9gNA,2344
9
+ pyproject.toml,sha256=zhu2wjrXmnpH5r_LXscKMezya9iLtxDqoAWpmqWS8-M,2344
10
10
  .git_hooks/pre-commit,sha256=n3RofIZHJl8zfJJIUomcMyYGFi_rwq4CC19z0snz3FI,286
11
11
  .gitlab/issue_templates/bug_report_template.md,sha256=gAuyEwl7XlnebBrkiJ9AqffSNOywmr8vygUFWKTuQeI,386
12
12
  .gitlab/issue_templates/documentation_update_template.md,sha256=FHLdb3TS_D9aL4CYZCjyXSulbaW5mrN2CmwTaeLPbNw,860
@@ -46,7 +46,7 @@ bec_widgets/utils/colors.py,sha256=GYSDe0ZxsJSwxvuy-yG2BH17qlf_Sjq8dhDcyp9IhBI,8
46
46
  bec_widgets/utils/container_utils.py,sha256=m3VUyAYmSWkEwApP9tBvKxPYVtc2kHw4toxIpMryJy4,1495
47
47
  bec_widgets/utils/crosshair.py,sha256=SubY4FQCI6vUKsmMYGKHR7uYdGQJ6vhoYLuC1XlKS9I,9626
48
48
  bec_widgets/utils/entry_validator.py,sha256=IqmtResXQtnmMvWVSl8IrnggqSzXLp4cSggn6WdSTpE,1298
49
- bec_widgets/utils/generate_designer_plugin.py,sha256=6-bPGULexbO02IcUBNqclSdNrZsWsCo-eAdzNpAYsGk,5703
49
+ bec_widgets/utils/generate_designer_plugin.py,sha256=T6DqL29sN4LcXLH8Hoa410UGnoRzjsZ-z0PRGTEzkRE,5809
50
50
  bec_widgets/utils/layout_manager.py,sha256=H0nKsIMaPxRkof1MEXlSmW6w1dFxA6astaGzf4stI84,4727
51
51
  bec_widgets/utils/plugin_utils.py,sha256=tmZkUNvVlldPjHDfL_TbaV2jjAECgPjGsvLMmmyZcfc,3342
52
52
  bec_widgets/utils/rpc_decorator.py,sha256=pIvtqySQLnuS7l2Ti_UAe4WX7CRivZnsE5ZdKAihxh0,479
@@ -201,6 +201,7 @@ tests/unit_tests/test_crosshair.py,sha256=3OMAJ2ZaISYXMOtkXf1rPdy94vCr8njeLi6uHb
201
201
  tests/unit_tests/test_device_input_base.py,sha256=DiwbNzFQ8o90ELhlT103roqLNEzJ09bvlpNrOmT4lfM,2423
202
202
  tests/unit_tests/test_device_input_widgets.py,sha256=yQ67Xwn-T7NHAIT1XLA4DvcxQEIJYMUr9PfPnT6CAPI,5805
203
203
  tests/unit_tests/test_generate_cli_client.py,sha256=adcMoXjWpFLVjpauCu0r31CMMibUY1LF1MMf8rO-6rw,2815
204
+ tests/unit_tests/test_generate_plugin.py,sha256=9603ucZChM-pYpHadzsR94U1Zec1KZT34WedX9qzgMo,4464
204
205
  tests/unit_tests/test_motor_control.py,sha256=NBekcGALo5mYkuyBJvBhvJkWiQDV82hI4GmsobRzjTI,20770
205
206
  tests/unit_tests/test_plot_base.py,sha256=Akr_JgglUCrtERtdtsMqWko_MLUYoAYRGzV2sum-YHo,3836
206
207
  tests/unit_tests/test_plugin_utils.py,sha256=PonKNpu4fZaFmKbI2v0tZJjZrsTvBGSF96bPHvKJvrE,608
@@ -221,8 +222,8 @@ tests/unit_tests/test_configs/config_device_no_entry.yaml,sha256=hdvue9KLc_kfNzG
221
222
  tests/unit_tests/test_configs/config_scan.yaml,sha256=vo484BbWOjA_e-h6bTjSV9k7QaQHrlAvx-z8wtY-P4E,1915
222
223
  tests/unit_tests/test_msgs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
223
224
  tests/unit_tests/test_msgs/available_scans_message.py,sha256=m_z97hIrjHXXMa2Ex-UvsPmTxOYXfjxyJaGkIY6StTY,46532
224
- bec_widgets-0.76.0.dist-info/METADATA,sha256=Zi2GSe-npT55crEiQspELhVGcx_gfEiW_E4Duz9AS-0,1407
225
- bec_widgets-0.76.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
226
- bec_widgets-0.76.0.dist-info/entry_points.txt,sha256=3otEkCdDB9LZJuBLzG4pFLK5Di0CVybN_12IsZrQ-58,166
227
- bec_widgets-0.76.0.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
228
- bec_widgets-0.76.0.dist-info/RECORD,,
225
+ bec_widgets-0.76.1.dist-info/METADATA,sha256=-U5bxfflX9Bl1WUPGgROel3NEW1D9GQROCFx6yvARMo,1407
226
+ bec_widgets-0.76.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
227
+ bec_widgets-0.76.1.dist-info/entry_points.txt,sha256=3otEkCdDB9LZJuBLzG4pFLK5Di0CVybN_12IsZrQ-58,166
228
+ bec_widgets-0.76.1.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
229
+ bec_widgets-0.76.1.dist-info/RECORD,,
pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "bec_widgets"
7
- version = "0.76.0"
7
+ version = "0.76.1"
8
8
  description = "BEC Widgets"
9
9
  requires-python = ">=3.10"
10
10
  classifiers = [
@@ -0,0 +1,155 @@
1
+ import importlib
2
+ import inspect
3
+ import os
4
+ import sys
5
+
6
+ import pytest
7
+
8
+ from bec_widgets.utils.generate_designer_plugin import DesignerPluginGenerator
9
+
10
+
11
+ def load_plugin(dir_path, content, plugin_name="MyWidget"):
12
+ plugin_path = dir_path.mkdir("plugin").join("plugin.py")
13
+ plugin_path.write(content)
14
+ sys.path.append(str(dir_path))
15
+ plugin = importlib.import_module("plugin.plugin")
16
+ importlib.reload(plugin)
17
+ yield getattr(plugin, plugin_name)
18
+ sys.path.pop()
19
+
20
+
21
+ @pytest.fixture(
22
+ params=[
23
+ """
24
+ from qtpy.QtWidgets import QWidget
25
+ class MyWidget(QWidget):
26
+ def __init__(self, parent=None):
27
+ QWidget.__init__(self, parent)
28
+ """,
29
+ """
30
+ from qtpy.QtWidgets import QWidget
31
+ class MyWidget(QWidget):
32
+ def __init__(self, parent=None):
33
+ QWidget.__init__(self, parent=parent)
34
+ """,
35
+ """
36
+ from qtpy.QtWidgets import QWidget
37
+ class MyWidget(QWidget):
38
+ def __init__(self, parent=None):
39
+ super().__init__(parent)
40
+ """,
41
+ """
42
+ from qtpy.QtWidgets import QWidget
43
+ class MyWidget(QWidget):
44
+ def __init__(self, parent=None):
45
+ super().__init__(parent=parent)
46
+ """,
47
+ """
48
+ from qtpy.QtWidgets import QWidget
49
+ class MyWidget(QWidget):
50
+ def __init__(self, parent=None):
51
+ super(QWidget, self).__init__(parent)"""
52
+ """
53
+ from qtpy.QtWidgets import QWidget
54
+ class MyWidget(QWidget):
55
+ def __init__(self, parent=None):
56
+ super(QWidget, self).__init__(parent=parent)
57
+ """,
58
+ ]
59
+ )
60
+ def plugin_with_correct_parent(tmpdir, request):
61
+ yield from load_plugin(tmpdir, request.param)
62
+
63
+
64
+ @pytest.fixture(
65
+ params=[
66
+ """
67
+ from qtpy.QtWidgets import QWidget
68
+ class MyWidget(QWidget):
69
+ def __init__(self, parent=None):
70
+ QWidget.__init__(self)
71
+ """,
72
+ """
73
+ from qtpy.QtWidgets import QWidget
74
+ class MyWidget(QWidget):
75
+ def __init__(self, parent=None):
76
+ super().__init__()
77
+ """,
78
+ """
79
+ from qtpy.QtWidgets import QWidget
80
+ class MyWidget(QWidget):
81
+ def __init__(self, parent=None):
82
+ super(QWidget, self).__init__()
83
+ """,
84
+ ]
85
+ )
86
+ def plugin_with_missing_parent(tmpdir, request):
87
+ yield from load_plugin(tmpdir, request.param)
88
+
89
+
90
+ def test_generate_plugin(plugin_with_correct_parent):
91
+ generator = DesignerPluginGenerator(plugin_with_correct_parent)
92
+ generator.run()
93
+ assert os.path.exists(f"{generator.info.base_path}/register_my_widget.py")
94
+ assert os.path.exists(f"{generator.info.base_path}/my_widget_plugin.py")
95
+ assert os.path.exists(f"{generator.info.base_path}/my_widget.pyproject")
96
+
97
+
98
+ def test_generate_plugin_with_missing_parent(plugin_with_missing_parent):
99
+ with pytest.raises(ValueError) as excinfo:
100
+ generator = DesignerPluginGenerator(plugin_with_missing_parent)
101
+ generator.run()
102
+ assert "Widget class MyWidget must call the super constructor with parent." in str(
103
+ excinfo.value
104
+ )
105
+
106
+
107
+ @pytest.fixture()
108
+ def plugin_with_excluded_widget(tmpdir):
109
+ content = """
110
+ from qtpy.QtWidgets import QWidget
111
+ class BECDock(QWidget):
112
+ def __init__(self, parent=None):
113
+ QWidget.__init__(self, parent)
114
+ """
115
+ yield from load_plugin(tmpdir, content, plugin_name="BECDock")
116
+
117
+
118
+ def test_generate_plugin_with_excluded_widget(plugin_with_excluded_widget, capsys):
119
+ generator = DesignerPluginGenerator(plugin_with_excluded_widget)
120
+ generator.run()
121
+ captured = capsys.readouterr()
122
+
123
+ assert "Plugin BECDock is excluded from generation." in captured.out
124
+ assert not os.path.exists(f"{generator.info.base_path}/register_bec_dock.py")
125
+ assert not os.path.exists(f"{generator.info.base_path}/bec_dock_plugin.py")
126
+ assert not os.path.exists(f"{generator.info.base_path}/bec_dock.pyproject")
127
+
128
+
129
+ @pytest.fixture(
130
+ params=[
131
+ """
132
+ from qtpy.QtWidgets import QWidget
133
+ class MyWidget(QWidget):
134
+ def __init__(self):
135
+ QWidget.__init__(self)
136
+ """,
137
+ """
138
+ from qtpy.QtWidgets import QWidget
139
+ class MyWidget(QWidget):
140
+ def __init__(self, config, parent=None):
141
+ super().__init__()
142
+ """,
143
+ ]
144
+ )
145
+ def plugin_with_no_parent_as_first_arg(tmpdir, request):
146
+ yield from load_plugin(tmpdir, request.param)
147
+
148
+
149
+ def test_generate_plugin_raises_exception_when_first_argument_is_not_parent(
150
+ plugin_with_no_parent_as_first_arg,
151
+ ):
152
+ with pytest.raises(ValueError) as excinfo:
153
+ generator = DesignerPluginGenerator(plugin_with_no_parent_as_first_arg)
154
+ generator.run()
155
+ assert "Widget class MyWidget must have parent as the first argument." in str(excinfo.value)