Skip to content

Commit 5f89653

Browse files
authored
Merge pull request #69 from LaboratoireMecaniqueLille/feature/add_deprecation_errors_from_1.5.11
Add deprecation errors for objects renamed between v1.5 and v2.0
2 parents bc0c43c + 5bf5217 commit 5f89653

File tree

11 files changed

+281
-3
lines changed

11 files changed

+281
-3
lines changed

src/crappy/actuator/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616

1717
from .meta_actuator import MetaActuator, Actuator
1818

19+
from ._deprecated import deprecated_actuators
1920
actuator_dict: Dict[str, Type[Actuator]] = MetaActuator.classes

src/crappy/actuator/_deprecated.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# coding: utf-8
2+
3+
deprecated_actuators = {'CM_drive': 'SchneiderMDrive23',
4+
'Fake_motor': 'FakeDCMotor',
5+
'Motorkit_pump': 'DCMotorHat',
6+
'Oriental': 'OrientalARDK',
7+
'Pololu_tic': 'PololuTic',
8+
'Servostar': 'ServoStar300',
9+
'Tra6ppd': 'NewportTRA6PPD'}

src/crappy/blocks/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@
3030

3131
from . import generator_path
3232
from . import camera_processes
33+
34+
from ._deprecated import (AutoDrive, Client_server, Displayer, DISVE, Drawing,
35+
Fake_machine, GUI, Hdf_recorder, Mean_block,
36+
Multiplex, Reader, Video_extenso)

src/crappy/blocks/_deprecated.py

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
# coding: utf-8
2+
3+
from .meta_block import Block
4+
5+
6+
class AutoDrive(Block):
7+
"""Empty class for signaling an object of version 1.5 whose name changed in
8+
version 2.0 and is now deprecated.
9+
10+
The new name of the correct object to use is given.
11+
"""
12+
13+
def __init__(self, *_, **__) -> None:
14+
"""Simply raises the exception when instantiating the object."""
15+
16+
super().__init__()
17+
18+
raise NotImplementedError(f"The {type(self).__name__} Block was renamed "
19+
f"to AutoDriveVideoExtenso in version 2.0.0 ! "
20+
f"Check the documentation for more information.")
21+
22+
23+
class Client_server(Block):
24+
"""Empty class for signaling an object of version 1.5 whose name changed in
25+
version 2.0 and is now deprecated.
26+
27+
The new name of the correct object to use is given.
28+
"""
29+
30+
def __init__(self, *_, **__) -> None:
31+
"""Simply raises the exception when instantiating the object."""
32+
33+
super().__init__()
34+
35+
raise NotImplementedError(f"The {type(self).__name__} Block was renamed "
36+
f"to ClientServer in version 2.0.0 ! "
37+
f"Check the documentation for more information.")
38+
39+
40+
class Displayer(Block):
41+
"""Empty class for signaling an object of version 1.5 that wa removed in
42+
version 2.0.O."""
43+
44+
def __init__(self, *_, **__) -> None:
45+
"""Simply raises the exception when instantiating the object."""
46+
47+
super().__init__()
48+
49+
raise NotImplementedError(f"The {type(self).__name__} Block was removed "
50+
f"in version 2.0.0 ! It is now contained "
51+
f"directly in the Camera Block. "
52+
f"Check the documentation for more information.")
53+
54+
55+
class DISVE(Block):
56+
"""Empty class for signaling an object of version 1.5 whose name changed in
57+
version 2.0 and is now deprecated.
58+
59+
The new name of the correct object to use is given.
60+
"""
61+
62+
def __init__(self, *_, **__) -> None:
63+
"""Simply raises the exception when instantiating the object."""
64+
65+
super().__init__()
66+
67+
raise NotImplementedError(f"The {type(self).__name__} Block was renamed "
68+
f"to DICVE in version 2.0.0 ! "
69+
f"Check the documentation for more information.")
70+
71+
72+
class Drawing(Block):
73+
"""Empty class for signaling an object of version 1.5 whose name changed in
74+
version 2.0 and is now deprecated.
75+
76+
The new name of the correct object to use is given.
77+
"""
78+
79+
def __init__(self, *_, **__) -> None:
80+
"""Simply raises the exception when instantiating the object."""
81+
82+
super().__init__()
83+
84+
raise NotImplementedError(f"The {type(self).__name__} Block was renamed "
85+
f"to Canvas in version 2.0.0 ! "
86+
f"Check the documentation for more information.")
87+
88+
89+
class Fake_machine(Block):
90+
"""Empty class for signaling an object of version 1.5 whose name changed in
91+
version 2.0 and is now deprecated.
92+
93+
The new name of the correct object to use is given.
94+
"""
95+
96+
def __init__(self, *_, **__) -> None:
97+
"""Simply raises the exception when instantiating the object."""
98+
99+
super().__init__()
100+
101+
raise NotImplementedError(f"The {type(self).__name__} Block was renamed "
102+
f"to FakeMachine in version 2.0.0 ! "
103+
f"Check the documentation for more information.")
104+
105+
106+
class GUI(Block):
107+
"""Empty class for signaling an object of version 1.5 whose name changed in
108+
version 2.0 and is now deprecated.
109+
110+
The new name of the correct object to use is given.
111+
"""
112+
113+
def __init__(self, *_, **__) -> None:
114+
"""Simply raises the exception when instantiating the object."""
115+
116+
super().__init__()
117+
118+
raise NotImplementedError(f"The {type(self).__name__} Block was renamed "
119+
f"to Button in version 2.0.0 ! "
120+
f"Check the documentation for more information.")
121+
122+
123+
class Hdf_recorder(Block):
124+
"""Empty class for signaling an object of version 1.5 whose name changed in
125+
version 2.0 and is now deprecated.
126+
127+
The new name of the correct object to use is given.
128+
"""
129+
130+
def __init__(self, *_, **__) -> None:
131+
"""Simply raises the exception when instantiating the object."""
132+
133+
super().__init__()
134+
135+
raise NotImplementedError(f"The {type(self).__name__} Block was renamed "
136+
f"to HDFRecorder in version 2.0.0 ! "
137+
f"Check the documentation for more information.")
138+
139+
140+
class Mean_block(Block):
141+
"""Empty class for signaling an object of version 1.5 whose name changed in
142+
version 2.0 and is now deprecated.
143+
144+
The new name of the correct object to use is given.
145+
"""
146+
147+
def __init__(self, *_, **__) -> None:
148+
"""Simply raises the exception when instantiating the object."""
149+
150+
super().__init__()
151+
152+
raise NotImplementedError(f"The {type(self).__name__} Block was renamed "
153+
f"to MeanBlock in version 2.0.0 ! "
154+
f"Check the documentation for more information.")
155+
156+
157+
class Multiplex(Block):
158+
"""Empty class for signaling an object of version 1.5 whose name changed in
159+
version 2.0 and is now deprecated.
160+
161+
The new name of the correct object to use is given.
162+
"""
163+
164+
def __init__(self, *_, **__) -> None:
165+
"""Simply raises the exception when instantiating the object."""
166+
167+
super().__init__()
168+
169+
raise NotImplementedError(f"The {type(self).__name__} Block was renamed "
170+
f"to Multiplexer in version 2.0.0 ! "
171+
f"Check the documentation for more information.")
172+
173+
174+
class Reader(Block):
175+
"""Empty class for signaling an object of version 1.5 whose name changed in
176+
version 2.0 and is now deprecated.
177+
178+
The new name of the correct object to use is given.
179+
"""
180+
181+
def __init__(self, *_, **__) -> None:
182+
"""Simply raises the exception when instantiating the object."""
183+
184+
super().__init__()
185+
186+
raise NotImplementedError(f"The {type(self).__name__} Block was renamed "
187+
f"to LinkReader in version 2.0.0 ! "
188+
f"Check the documentation for more information.")
189+
190+
191+
class Video_extenso(Block):
192+
"""Empty class for signaling an object of version 1.5 whose name changed in
193+
version 2.0 and is now deprecated.
194+
195+
The new name of the correct object to use is given.
196+
"""
197+
198+
def __init__(self, *_, **__) -> None:
199+
"""Simply raises the exception when instantiating the object."""
200+
201+
super().__init__()
202+
203+
raise NotImplementedError(f"The {type(self).__name__} Block was renamed "
204+
f"to VideoExtenso in version 2.0.0 ! "
205+
f"Check the documentation for more information.")

src/crappy/blocks/camera.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from .meta_block import Block
1515
from .camera_processes import Displayer, ImageSaver, CameraProcess
16-
from ..camera import camera_dict, Camera as BaseCam
16+
from ..camera import camera_dict, Camera as BaseCam, deprecated_cameras
1717
from ..tool.camera_config import CameraConfig
1818
from .._global import CameraPrepareError, CameraRuntimeError, CameraConfigError
1919

@@ -206,6 +206,13 @@ def __init__(self,
206206
self.niceness = -10
207207
self.debug = debug
208208

209+
# Checking for deprecated names
210+
if camera in deprecated_cameras:
211+
raise NotImplementedError(
212+
f"The {camera} Camera was deprecated in version 2.0.0, and renamed "
213+
f"to {deprecated_cameras[camera]} ! Please update your code "
214+
f"accordingly and check the documentation for more information")
215+
209216
# Checking if the requested camera exists in Crappy
210217
if image_generator is None:
211218
if camera not in camera_dict:

src/crappy/blocks/ioblock.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import logging
55

66
from .meta_block import Block
7-
from ..inout import inout_dict, InOut
7+
from ..inout import inout_dict, InOut, deprecated_inouts
88
from ..tool.ft232h import USBServer
99

1010

@@ -156,6 +156,13 @@ def __init__(self,
156156

157157
self._trig_label = trigger_label
158158

159+
# Checking for deprecated names
160+
if name in deprecated_inouts:
161+
raise NotImplementedError(
162+
f"The {name} InOut was deprecated in version 2.0.0, and renamed "
163+
f"to {deprecated_inouts[name]} ! Please update your code "
164+
f"accordingly and check the documentation for more information")
165+
159166
# Checking that all the given actuators are valid
160167
if name not in inout_dict:
161168
possible = ', '.join(sorted(inout_dict.keys()))

src/crappy/blocks/machine.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import logging
77

88
from .meta_block import Block
9-
from ..actuator import actuator_dict, Actuator
9+
from ..actuator import actuator_dict, Actuator, deprecated_actuators
1010
from ..tool.ft232h import USBServer
1111

1212

@@ -144,6 +144,15 @@ def __init__(self,
144144
# The list of all the Actuator types to instantiate
145145
self._types = [actuator['type'] for actuator in actuators]
146146

147+
# Checking for deprecated names
148+
deprecated = [type_ for type_ in self._types
149+
if type_ in deprecated_actuators]
150+
for type_ in deprecated:
151+
raise NotImplementedError(
152+
f"The {type_} Actuator was deprecated in version 2.0.0, and renamed "
153+
f"to {deprecated_actuators[type_]} ! Please update your code "
154+
f"accordingly and check the documentation for more information")
155+
147156
# Checking that all the given actuators are valid
148157
if not all(type_ in actuator_dict for type_ in self._types):
149158
unknown = ', '.join(tuple(type_ for type_ in self._types if type_

src/crappy/camera/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@
2727
else:
2828
from .gstreamer_camera_basic import CameraGstreamer
2929

30+
from ._deprecated import deprecated_cameras
3031
camera_dict: Dict[str, Type[Camera]] = MetaCamera.classes

src/crappy/camera/_deprecated.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# coding: utf-8
2+
3+
deprecated_cameras = {'Bispectral': 'BiSpectral',
4+
'Cl_camera': 'BaslerIronmanCameraLink',
5+
'Fake_camera': 'FakeCamera',
6+
'File_reader': 'FileReader',
7+
'Camera_gstreamer': 'CameraGstreamer',
8+
'Jai8': 'JaiGO5000CPMCL8Bits',
9+
'Jai': 'JaiGO5000CPMCL',
10+
'Camera_opencv': 'CameraOpencv',
11+
'Picamera': 'RaspberryPiCamera',
12+
'Seek_thermal_pro': 'SeekThermalPro',
13+
'Xiapi': 'XiAPI'}

src/crappy/inout/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@
3434
from .meta_inout import InOut, MetaIO
3535

3636
# All the inout objects
37+
from ._deprecated import deprecated_inouts
3738
inout_dict: Dict[str, Type[InOut]] = MetaIO.classes

0 commit comments

Comments
 (0)